Skip to content

Commit f204bba

Browse files
committed
adjust webpack setting
1 parent afb6957 commit f204bba

File tree

1 file changed

+24
-15
lines changed

1 file changed

+24
-15
lines changed

webpack.config.js

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,19 @@
11
const pkg = require('./package.json');
22

3-
const comment = `@yama-dev/${pkg.name} Version ${pkg.version} Repository ${pkg.repository.url} Copyright ${pkg.author} Licensed ${pkg.license}`;
3+
const comment = `/*! @yama-dev/${pkg.name} Version ${pkg.version} Repository ${pkg.repository.url} Copyright ${pkg.author} Licensed ${pkg.license} */`;
44

55
const env = process.env.NODE_ENV;
66

7+
if(!env) process.exit(1);
8+
79
const webpack = require('webpack');
10+
const TerserPlugin = require('terser-webpack-plugin');
811

912
const webpackPlugEnv = new webpack.EnvironmentPlugin({
10-
NODE_ENV: 'development',
1113
DEBUG: false,
1214
VERSION: pkg.version
1315
});
1416

15-
const webpackPlugBnr = new webpack.BannerPlugin({
16-
banner: comment,
17-
});
18-
19-
const babelPlugin = [
20-
'@babel/plugin-transform-object-assign'
21-
];
22-
2317
const config = {
2418
mode: env || 'development',
2519
entry: {
@@ -42,7 +36,7 @@ const config = {
4236
},
4337
{
4438
test: /\.js$/,
45-
exclude: /node_modules[//\/](?!(@yama\-dev)\/).*/,
39+
exclude: /node_modules[///](?!(@yama-dev)\/).*/,
4640
use: {
4741
loader: 'babel-loader',
4842
options: {
@@ -53,17 +47,32 @@ const config = {
5347
modules: false
5448
}
5549
]
56-
],
57-
plugins: babelPlugin
50+
]
5851
}
5952
}
6053
}
6154
]
6255
},
56+
target: ['web', 'es5'],
6357
plugins: [
6458
webpackPlugEnv,
65-
webpackPlugBnr
66-
]
59+
],
60+
optimization: {
61+
minimizer: [
62+
new TerserPlugin({
63+
extractComments: false,
64+
terserOptions: {
65+
output: {
66+
preamble: comment,
67+
comments: false,
68+
},
69+
compress: {
70+
drop_console: true
71+
}
72+
},
73+
}),
74+
],
75+
}
6776
};
6877

6978
module.exports = config;

0 commit comments

Comments
 (0)