-
Notifications
You must be signed in to change notification settings - Fork 163
/
webpack.config.js
74 lines (72 loc) · 2.65 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
const path = require('path');
const child_process = require('child_process');
const webpack = require('webpack');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
module.exports = (env = {}) => {
const pkg = require('./package.json');
const githash = child_process.execSync('git rev-parse --short=7 HEAD', { encoding: 'utf8' }).trim();
return {
mode: env.production ? 'production' : 'development',
entry: {
'bundle/husky-range': './workspace/src/bundle/husky-range.js',
'bundle/base': './workspace/src/bundle/base.js',
'bundle/extra': './workspace/src/bundle/extra.js',
'bundle/lazy': './workspace/src/bundle/lazy.js',
'bundle/index': './workspace/src/bundle/index.js',
'smarteditor2': './workspace/src/bundle/index.js'
},
output: {
filename: 'js/[name].js',
path: path.resolve(__dirname, 'dist')
},
module: {
rules: [
{
test: /bundle\/.*\.js$/,
exclude: [
/node_modules/,
],
query: {
presets: [
['env', {
targets: {
browsers: ['ie >= 8']
},
loose: true
}]
],
"plugins": [
"transform-es3-property-literals",
"transform-es3-member-expression-literals"
]
},
loader: "babel-loader"
}
]
},
plugins: [
new CleanWebpackPlugin(),
new CopyWebpackPlugin([
'workspace/static'
]),
new webpack.DefinePlugin({
__VERSION__: JSON.stringify(pkg.version),
__HASH__: JSON.stringify(githash)
}),
new webpack.BannerPlugin('Copyright (C) NAVER corp. Licensed under LGPL v2. @see https://github.com/naver/smarteditor2/blob/master/LICENSE.md')
],
optimization: {
minimizer: [new UglifyJsPlugin({
uglifyOptions: {
ie8: true
}
})]
},
devServer: {
contentBase: path.join(__dirname, 'dist'),
openPage: 'SmartEditor2.html'
}
};
};