-
Notifications
You must be signed in to change notification settings - Fork 27.1k
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
Custom webpack config #40
Comments
Is this currently unsupported full stop? e.g. there is no way for me to add css-loader to parse .css files via Webpack? |
You could make a layer that implements Tapable and let people plugin to the instance. :) easy plugin system. |
Or if anything a hook before build and dev that can return the 'compiler' instance or 'config object' before it calls .run or .watch. This would provide a single extensible point in which people can explore customize, break, or change the configuration to suit their snowflake applications/workflows. |
Adding css is pretty important. For the time being, I just leveraged Example
|
would this be considered a webpack issue? wondering if having access to the config could resolve this |
Custom webpack config would be incredible, I'm trying to use react-toolbox but without a SASS loader, I can't do much... Is there an unofficial way to include a custom webpack config at this point? |
IMO, there are two ways of solving this
|
This solution sounds pretty good |
A simple option could be to try load user's webpack config, falling back to default config. User's config would totally overrides the default config, however, the default config would be loadable e.g Then the user could use whatever to extend/mutate this. e.g. const nextConfig = require('next/webpack.config')
module.exports = Object.assign({}, nextConfig, {
devtool: 'eval-source-map'
}) For example, override customise the babel transforms config as needed (#26): const nextConfig = require('next/webpack.config')
// find babel loader
const babelLoader = nextConfig.module.loaders.find(({loader}) => loader === 'babel')
// mutate to add custom plugin
babelLoader.plugins.unshift('transform-decorators-legacy') // must run first
module.exports = nextConfig Would also allow users to opt into using something with fancy recursive merging logic like const Config = require('webpack-config')
module.exports = new Config().merge(require.resolve('next/webpack.config'), {
resolve: {
alias: {
'immutable': require.resolve('immutable/dist/immutable.min.js')
}
}
}) Ideally, this would only need to be used as an escape hatch for emergencies. |
What do you think about #174 ? Given it's safe to mutate original config and small chances that someone would like to override config completely, I'd not ask end user to return anything from the function. It would be original config object anyway. |
I like @timoxley's suggestion above. |
@nickjackson return Object.assign({}, nextConfig, {
devtool: 'eval-source-map'
}) looks more familiar then? nextConfig.devtool = 'eval-source-map' I could add return value to API and it would not significantly change suggested usage, but it will make developers think that they have to clone original config while they are not required to do it. It would make usage too complicated if we require developers to keep original config unchanged. |
@vdanchenkov using the returned object would allow users to mutate or clone or return an entirely new object. Your current implementation only allows users the option to mutate. Not sure if this approach is the right avenue or not though. |
The people at https://github.com/kadirahq/react-storybook have implemented a custom webpack config loader for their app which users can easily add to. |
@pyros2097 Thanks for the mention. Yep, we allow both webpack and babel and it's working pretty well. FYI: This is how we do it. @rauchg, if this is something you'd like to see, I'm happy to work on this. |
Are there any open questions left on this? I really like the idea of the API converging with |
Please see #174. It's very possible that we'll admit both a function and an object in the future, but we'll start with the more powerful variant (fn) |
@rauchg Oh, cool. Thanks for the update! |
It'd be nice to add hooks for webpack, and describe on the README (similarly to #26) how to for example add
require('./something.css')
support.The text was updated successfully, but these errors were encountered: