Skip to content
This repository was archived by the owner on Jan 13, 2025. It is now read-only.

Commit c25d387

Browse files
codesukisgomes
authored andcommitted
fix(webpack): Fix uglifyjs breaking and disable modules for webpack tree 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.
1 parent 1cd9e07 commit c25d387

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

package.json

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,23 @@
8080
},
8181
"babel": {
8282
"presets": [
83-
"es2015"
83+
[
84+
"es2015",
85+
{
86+
"modules": false
87+
}
88+
]
8489
],
8590
"plugins": [
8691
"transform-object-assign"
87-
]
92+
],
93+
"env": {
94+
"test": {
95+
"presets": [
96+
"es2015"
97+
]
98+
}
99+
}
88100
},
89101
"config": {
90102
"validate-commit-msg": {

webpack.config.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ const createBannerPlugin = () => new webpack.BannerPlugin({
4141
entryOnly: true,
4242
});
4343

44+
const LIFECYCLE_EVENT = process.env.npm_lifecycle_event;
45+
if (LIFECYCLE_EVENT == 'test' || LIFECYCLE_EVENT == 'test:watch') {
46+
process.env.BABEL_ENV = 'test';
47+
}
48+
4449
module.exports = [{
4550
name: 'js-components',
4651
entry: {
@@ -92,7 +97,6 @@ module.exports = [{
9297
module: {
9398
rules: [{
9499
test: /\.js$/,
95-
include: [path.resolve(__dirname, 'packages/material-components-web')],
96100
exclude: /node_modules/,
97101
loader: 'babel-loader',
98102
options: {

0 commit comments

Comments
 (0)