-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
84 lines (71 loc) · 1.51 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
75
76
77
78
79
80
81
82
83
84
const webpack = require('webpack');
const path = require('path');
const isProduction = process.env.NODE_ENV == 'production' ? true : false;
const webpack_config = {
plugins: [],
module: {
loaders: []
}
};
webpack_config.entry = {
'vue-lifecycle': './src/vue-lifecycle.js',
};
if(isProduction) {
webpack_config.entry['vue-lifecycle.min'] = './src/vue-lifecycle.js';
}
webpack_config.output = {
path: path.resolve(__dirname, 'dist'),
filename: '[name].js',
libraryTarget: 'umd',
};
webpack_config.plugins.push(
new webpack.DefinePlugin({ isProduction })
);
webpack_config.module.loaders.push({
test: /\.js$/,
exclude: ['node_modules'],
loaders: [
{
loader: 'babel-loader',
options: {
presets: ['env', 'stage-2']
}
},
]
});
if(!isProduction) {
const BrowserSyncPlugin = require('browser-sync-webpack-plugin');
webpack_config.plugins.push(
new BrowserSyncPlugin({
host: 'localhost',
port: 1337,
files: [
'./dist/**/*',
'./demos/**/*',
],
server: {
baseDir: ['./'],
index: '/demos/index.html'
}
})
);
webpack_config.watch = true;
webpack_config.watchOptions = {
aggregateTimeout: 100,
ignored: /node_modules/
};
webpack_config.devtool = 'cheap-inline-module-source-map';
}
else {
webpack_config.plugins.push(
new webpack.optimize.UglifyJsPlugin({
include: /\.min\.js$/,
minimize: true,
beautify: false,
sourceMap: false,
compress: { warnings: false },
output: { comments: false }
})
);
}
module.exports = webpack_config;