forked from Draggable/i18n
-
Notifications
You must be signed in to change notification settings - Fork 1
/
webpack.config.js
59 lines (55 loc) · 1.37 KB
/
webpack.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
const pkg = require('./package.json')
const { resolve } = require('path')
const { BannerPlugin } = require('webpack')
const CompressionPlugin = require('compression-webpack-plugin')
const UglifyJsPlugin = require('uglifyjs-webpack-plugin')
const bannerTemplate = [`${pkg.name} - ${pkg.homepage}`, `Version: ${pkg.version}`, `Author: ${pkg.author}`].join('\n')
const plugins = [
new UglifyJsPlugin(),
new BannerPlugin(bannerTemplate),
new CompressionPlugin({
asset: '[path].gz[query]',
algorithm: 'gzip',
test: /\.(js)$/,
threshold: 10240,
minRatio: 0.8,
}),
]
const webpackConfig = env => ({
mode: env.production ? 'production' : 'development',
context: resolve(__dirname),
entry: {
mi18n: './src/mi18n.js',
},
output: {
path: resolve(__dirname, 'dist'),
libraryTarget: 'commonjs2',
filename: '[name].min.js',
},
module: {
rules: [
{
enforce: 'pre',
test: /\.js$/,
exclude: /node_modules/,
loader: 'eslint-loader',
},
{
test: /\.js$/,
loader: 'babel-loader',
},
],
},
devtool: env.production && 'inline-source-map',
plugins,
resolve: {
modules: [resolve(__dirname, 'src'), 'node_modules'],
extensions: ['.js', '.json'],
},
devServer: {
inline: true,
contentBase: 'demo/',
noInfo: true,
},
})
module.exports = webpackConfig