Skip to content

feat(webpack): export webpack's config builder classes#5366

Closed
damianstasik wants to merge 1 commit intonuxt:devfrom
damianstasik:patch-1
Closed

feat(webpack): export webpack's config builder classes#5366
damianstasik wants to merge 1 commit intonuxt:devfrom
damianstasik:patch-1

Conversation

@damianstasik
Copy link
Copy Markdown

Types of changes

  • Bug fix (a non-breaking change which fixes an issue)
  • New feature (a non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Description

Currently there is no way to extract a webpack config from a Nuxt project, because there is no access to WebpackClientConfig, WebpackServerConfig and WebpackModernConfig.

Here is what I wanted to do:

const { Builder } = require('@nuxt/builder');
const { Nuxt } = require('@nuxt/core');
const { WebpackClientConfig } = require('@nuxt/webpack'); // currently not exported

const nuxt = new Nuxt();
const builder = new Builder(nuxt);
console.log(new WebpackClientConfig(builder.getBundleBuilder()).config()); // webpack config

Checklist:

  • My change requires a change to the documentation.
  • I have updated the documentation accordingly. (PR: #)
  • I have added tests to cover my changes (if not applicable, please state why)
  • All new and existing tests are passing.

@codecov-io
Copy link
Copy Markdown

codecov-io commented Mar 24, 2019

Codecov Report

Merging #5366 into dev will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@         Coverage Diff          @@
##            dev   #5366   +/-   ##
====================================
  Coverage    96%     96%           
====================================
  Files        74      74           
  Lines      2529    2529           
  Branches    640     640           
====================================
  Hits       2428    2428           
  Misses       85      85           
  Partials     16      16

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 920dcac...69181a9. Read the comment docs.

@pi0
Copy link
Copy Markdown
Member

pi0 commented Mar 24, 2019

What about adding getConfig(name) to the webpack/builder.js?

const { Builder } = require('@nuxt/builder');
const { Nuxt } = require('@nuxt/core');

const nuxt = new Nuxt()
const builder = new Builder(nuxt)
const bundleBuilder = builder.getBundleBuilder()

console.log(bundleBuilder.getConfig('server'))

Exporting is probably the easiest way, but I'm suggesting this because there is no guarantee about refactors on 3rd level packages and breaking the way of usage which is proposed in PR.

@damianstasik
Copy link
Copy Markdown
Author

@pi0 wasn't sure if you would accept a new API, but having such method would be awesome! Here is a new PR which adds such method to WebpackBundler.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants