-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
94 lines (90 loc) · 2.64 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
85
86
87
88
89
90
91
92
93
94
const webpack = require('webpack');
const path = require('path');
const WebpackNotifierPlugin = require('webpack-notifier');
const WebpackZipPlugin = require('webpack-zip-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const CleanWebpackPlugin = require('clean-webpack-plugin');
const Crx = require('crx-webpack-plugin');
const pkg = require('./package.json');
function resolve (dir) {
return path.join(__dirname, '..', dir)
}
const config = {
entry: {
background: './src/js/background.js',
attendant: './src/js/attendant/index.js',
customer: './src/js/customer/index.js',
vendor: Object.keys(pkg.dependencies)
},
output: {
filename: '[name].js',
path: path.resolve(__dirname, 'build')
},
resolve: {
extensions: ['.js', '.vue', '.json'],
alias: {
'vue$': 'vue/dist/vue.runtime.esm.js',
'@': path.resolve(__dirname, 'dist')
}
},
module: {
rules: [
{
test: /\.vue$/,
loader: 'vue-loader',
},
{
test: /\.js$/,
loader: 'babel-loader',
include: path.resolve(__dirname, 'src/js')
}
]
},
watchOptions: {
ignored: /node_modules/
},
plugins: [
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV)
}),
new webpack.optimize.CommonsChunkPlugin({
name: 'vendor',
filename: 'vendor.bundle.js'
}),
new WebpackNotifierPlugin(),
new CleanWebpackPlugin(['build']),
new CopyWebpackPlugin([
{ from: 'manifest.json', to: 'manifest.json' },
{ from: 'assets', to: 'assets' },
{ from: 'src/css', to: 'css' },
{ from: 'src/html', to: './' },
{ from: 'src/js/standalone', to: './' }
])
]
};
if(process.env.NODE_ENV === 'production') {
console.log('PRODUCTION');
/*config.plugins.push(new webpack.optimize.UglifyJsPlugin({
compress: {
screw_ie8: true
}
}));*/
config.plugins.push(new CleanWebpackPlugin(['dist']));
config.plugins.push(new WebpackZipPlugin({
frontShell: 'ls && pwd',
initialFile: 'build',
endPath: './dist',
zipName: 'printcenter.zip'
}));
config.plugins.push(new Crx({
keyFile: './key.pem',
contentPath: './build',
outputPath: './dist',
name: 'printcenter'
}));
}
else {
console.log('DEVELOPMENT');
config.devtool = '#source-map';
}
module.exports = config;