-
-
Notifications
You must be signed in to change notification settings - Fork 10.7k
Webpack everything #626
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
Webpack everything #626
Conversation
2fb8f1a
to
f041c2a
Compare
@sokra I'm digging a bit further, basically just putting a bunch of debug statements in the
It looks like |
f041c2a
to
144e8cc
Compare
690fce6
to
7a0c786
Compare
9742434
to
4443baf
Compare
You still need any help on this? |
This looks awesome. I've been wanting to do it but haven't made the time for it. I've been wondering if we ought to run the test suite against the global build too, now might be a good time to do that? Or I guess we can do a commit after this. |
package.json
Outdated
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've always preferred the other way, have the npm run
scripts simply call a scripts/something
so that you don't do too much in here (and so the scripts are more portable), but anyway ... I don't care enough to say "no" to this commit.
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've been leaning more and more towards putting as much in my package.json as I can. It's more portable, and keeps a bunch of extra files from popping up in my repos.
Uh ... this creates a 👎 |
new webpack.DefinePlugin({
'process.env': {
'NODE_ENV': whatever
}
}),
seems like it doesn't: envifying actually worked |
Also, there's a whole React in there.. |
I think you forgot this in Webpack config: externals: {
'react': 'React'
}, |
that looks right http://webpack.github.io/docs/library-and-externals.html |
That drops it down to 18kb gzipped. 5kb gzipped doesn't seem like its worth using webpack for the global build. |
How do you check length? |
when you run |
Indeed, using Webpack's Uglify plugin gives better results than having it as a separate step. |
oh are we double minifying? |
Not double minifying, but for some reason, letting Webpack uglify itself (by using its plugin) works better than uglifying later. |
still 2kb bigger than the browserify build ... hmmmmmmm |
I think I got it to 10619, wonder if it's working.. |
My config: var webpack = require('webpack');
module.exports = {
// don't include Node Buffer polyfill (why is it there by default?)
// http://webpack.github.io/docs/configuration.html#node
node: {
buffer: false
},
output: {
library: 'ReactRouter',
libraryTarget: 'var'
},
externals: {
'react': 'React'
},
plugins: [
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV || 'production')
}),
// let Webpack uglify
new webpack.optimize.UglifyJsPlugin({
compressor: {
warnings: false
}
})
]
}; This is for the minimized file, you don't need to Note Webpack by default include Buffer polyfill, I excluded that. I haven't checked if this works. |
@gaearon Good call. Using webpack's uglify plugin gets the global build down to 10k @rpflorence saved 3k! |
Awesome, hopefully it still works. I'd like to have a non-minified version too, still. We've got apps that need the global build but we don't want it minified in dev. |
Yeah, you just need to push or not push that plugin based on a condition (env?) |
c543305
to
ffe3e46
Compare
@rpflorence Updated. Everything should still work fine. We don't rely on the Buffer module for anything, and we're not doing anything fancy with uglify. |
👍 |
@sokra While you’re here, curious: why is Buffer in by default?
|
Sorry I'm on vacation and cannot investigate in detail, but you can see it in the analyse tool or with |
Ah, have a good rest! |
// qs/lib/utils.js
exports.isBuffer = function (obj) {
if (typeof Buffer !== 'undefined') {
return Buffer.isBuffer(obj);
}
else {
return false;
}
}; The newer version solved it in another way. You just need to upgrade to |
Done! Thanks @sokra Michael Jackson On Mon, Dec 22, 2014 at 6:06 AM, Tobias Koppers notifications@github.com
|
This branch is an attempt to use webpack to build our tests instead of Browserify.
I'm currently having an issue that I hope @sokra can help with in this branch. When I run
./scripts/test
I get the following error:Digging a bit deeper, it looks like the memory-fs module is having problems finding some of the files it needs. The two errors I'm seeing are:
@sokra Would you mind taking a look at this branch and telling me what I'm doing wrong?