Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Supporting custom webpack.config.js #16

Closed
indexzero opened this issue Aug 23, 2017 · 10 comments
Closed

Supporting custom webpack.config.js #16

indexzero opened this issue Aug 23, 2017 · 10 comments

Comments

@indexzero
Copy link

Interested in using your project, but the projects in which we would be using it do not build using the webpack config included in index.js.

Would you be interested in a PR that allows for a custom webpack config file path to be provided?

e.g.

size-limit --config ./webpack.config.js

The webpack.config.js file would be expected to:

  • Export a single webpack config object
  • Not include any compression or minification plugins

... thoughts?

@ai
Copy link
Owner

ai commented Aug 23, 2017

Sure. Let's do it. Do you want to make PR?

Also, why custom config should not include compression and minification plugins? What if users will want to customize them too?

@indexzero
Copy link
Author

Totally possible. I was assuming that the Compression and Uglify plugins the webpack config in index.js uses were intentional. e.g. what would happen if one attempted to use require('webpack').optimize.UglifyJsPlugin instead of require('uglifyjs-webpack-plugin')?

@ai
Copy link
Owner

ai commented Aug 23, 2017

uglifyjs-webpack-plugin loads latest beta with ES6 support

@indexzero
Copy link
Author

Got it. What I'm trying to figure out is the best way to (or if it's feasible) to implement the following:

  • Is it possible to determine if an arbitrary webpack config object, config, needs modification by size-limit?

In other words: what's an efficient way to check if config.plugins has both a compatible minifier plugin and a compatible compression plugin?

@ai
Copy link
Owner

ai commented Aug 26, 2017

I think we could ignore this problem. If you pass custom config, it is your responsibility now.

If we will have a lot of issues, we can add check later.

@indexzero
Copy link
Author

That's reasonable. Will take a stab at this in the next couple of weeks.

@SivanMehta
Copy link
Contributor

SivanMehta commented Oct 27, 2017

@indexzero @ai I have submitted #29, and #31 to enable a --config flag that supports a custom webpack config.

@ai ai closed this as completed Oct 29, 2017
@ai
Copy link
Owner

ai commented Oct 29, 2017

Released in 0.12

@oliviertassinari
Copy link
Contributor

@SivanMehta I'm wondering, how are you using this --config option? How do you handle the files option?

size-limit/index.js

Lines 32 to 49 in 2286080

if (opts.config) {
let config
if (path.isAbsolute(opts.config)) {
config = require(opts.config)
} else {
config = require(path.join(process.cwd(), opts.config))
}
let resolveModulesPaths = [
path.join(process.cwd(), 'node_modules')
]
if (!config.resolveLoader) config.resolveLoader = { }
if (!config.resolve) config.resolve = { }
config.resolveLoader.modules = resolveModulesPaths
config.resolve.modules = resolveModulesPaths
return config
}

@SivanMehta
Copy link
Contributor

This PR should have supported the usage as described in the initial issue descriptions

size-limit --config ./my-custom-webpack.config.js

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants