Skip to content

Commit

Permalink
fix(webpack): Fix uglifyjs breaking and disable modules for webpack t…
Browse files Browse the repository at this point in the history
…ree shaking to work

Uglify broke because of the include statement I added in hope it would speed up the build.

To use tree shaking with webpack babel should not convert modules into es5 code. That broke the testing process.
I added a babel environment variable and environment babel rules switch to make both work.
  • Loading branch information
codesuki authored and sgomes committed Feb 9, 2017
1 parent 1cd9e07 commit c25d387
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
16 changes: 14 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,23 @@
},
"babel": {
"presets": [
"es2015"
[
"es2015",
{
"modules": false
}
]
],
"plugins": [
"transform-object-assign"
]
],
"env": {
"test": {
"presets": [
"es2015"
]
}
}
},
"config": {
"validate-commit-msg": {
Expand Down
6 changes: 5 additions & 1 deletion webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ const createBannerPlugin = () => new webpack.BannerPlugin({
entryOnly: true,
});

const LIFECYCLE_EVENT = process.env.npm_lifecycle_event;
if (LIFECYCLE_EVENT == 'test' || LIFECYCLE_EVENT == 'test:watch') {
process.env.BABEL_ENV = 'test';
}

module.exports = [{
name: 'js-components',
entry: {
Expand Down Expand Up @@ -92,7 +97,6 @@ module.exports = [{
module: {
rules: [{
test: /\.js$/,
include: [path.resolve(__dirname, 'packages/material-components-web')],
exclude: /node_modules/,
loader: 'babel-loader',
options: {
Expand Down

0 comments on commit c25d387

Please sign in to comment.