-
-
Notifications
You must be signed in to change notification settings - Fork 375
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
feature: Custom config #56
feature: Custom config #56
Conversation
I'm using Webpack 1 terms, but Webpack 2 is pretty much similar Most of the time, I usually need to do these thing with Webpack config:
|
Agreed with point about babelrc - I was actually thinking we'd manually parse it and apply the changes, but that might be somewhat difficult. Curious to hear your thoughts around that.
|
@developit we're in the luck - babel-loader allows passing presets and babel-config already conforms to babel-preset format. I've created some helpers - the idea behind them was that given rule index and loader index you can do pretty much everywhere (modify, remove, add). |
src/lib/babel-config.js
Outdated
@@ -4,7 +4,7 @@ export default (env, options={}) => ({ | |||
loose: true, | |||
modules: options.modules || false, | |||
uglify: true, | |||
browsers: env.browsers ? env.browsers.split() : [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
env.browsers was never passed here, in babel-preset env argument means something different so I've removed it
src/lib/webpack-config.js
Outdated
@@ -105,8 +105,8 @@ export default env => { | |||
pkg = readJson(manifest) || {}; | |||
return !!(pkg.module || pkg['jsnext:main']); | |||
}, | |||
babelrc: false, | |||
...createBabelConfig(env) | |||
babelrc: true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can't have this. This is the reason for #9. Even though it's been set to false
, it wasn't actually making it to the babel compiler.
I have a PR incoming for this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, nah - I've checked this it works for the cases specified in #9, the exlude: []
messes things up - babelrc is innocent 😛.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I forgot to come back here and update this comment. 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i merged the other one before reading this 🤓
…onfig # Conflicts: # src/lib/webpack-config.js
…onfig # Conflicts: # src/lib/run-webpack.js
Good stuff dude! |
…onfig # Conflicts: # src/commands/build.js # src/commands/watch.js
…onfig # Conflicts: # src/lib/webpack/webpack-base-config.js
…onfig # Conflicts: # package.json # tests/build.snapshot.js # tests/build.test.js
@@ -52,9 +52,9 @@ export default { | |||
'bundle.js': { size: 18460 }, | |||
'bundle.js.map': { size: 101500 }, | |||
'route-home.chunk.*.js': { size: 1020 }, | |||
'route-home.chunk.*.js.map': { size: 4980 }, | |||
'route-home.chunk.*.js.map': { size: 4283 }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Babel query got smaller (using preset now rather than passing options object).
The most anticipated PR of the repo has landed 🛩 |
This is great because I just started to use Preact and needed to proxy to Express like I could with CRA. Couldn't figure it out until I read this thread. Thanks! @lukeed |
@andywillis How did you manage it? |
@adc17, I used a preact.config.js file with the following (you should adjust it for your requirements): module.exports = function (config) {
if (process.env.NODE_ENV === 'development') {
config.devServer.proxy = [
{
// proxy requests matching a pattern:
path: '/entries',
// where to proxy to:
target: 'http://localhost:3001',
}
];
}
}; |
Does this support parcel as well as webpack, or just webpack? I can't get it working with parcel... |
Basically this adds support for custom webpack configuration transforms via
preact.config.js
file.To do:
babel preset for preact-cliallow .babelrc & extend from existing configExample config setting custom template:
Function exported in preact.config.js would take following parameters:
@developit, @cedric-marcone you had an idea to include .babelrc provided in folder.
I don't think it's a good idea without some changes. Current config has some great plugins (e.g. 'babel-plugin-transform-react-constant-elements', 'babel-plugin-transform-react-remove-prop-types') - which would be lost. If there's new cool plugin increasing performance by 100% which the end user doesn't know about he won't be included if preact-cli decides to add it.
I think babel preset that would be preact-cli specific would solve that issue. What do you think?
@thangngoc89 you had an idea to create some helpers, did you have anything specific in mind? I fully agree modifying webpack config is rather painful experience.
My ideas include:
Anywho, waiting for your opinions.