-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathwebpack.config.js
97 lines (86 loc) · 2.25 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
95
const path = require('path');
const webpack = require('webpack');
const shell = require('shelljs');
const UglifyJsPlugin = require('uglifyjs-webpack-plugin')
const outputPath = path.resolve( __dirname, 'assets/js')
const isProduction = (process.env.NODE_ENV == 'production')
const plugins = []
//Remove all webpack build file
shell.rm('-rf', outputPath)
function resolve (dir) {
return path.join(__dirname, './assets/src', dir)
}
if (isProduction) {
plugins.push(
new UglifyJsPlugin()
)
}
module.exports = {
entry: {
'hrm': './assets/src/start.js',
// 'library': './assets/src/helpers/library.js',
},
output: {
path: outputPath,
filename: '[name].js',
publicPath: '',
chunkFilename: 'chunk/[chunkhash].chunk-bundle.js',
jsonpFunction: 'wpSpearHrm',
},
resolve: {
extensions: ['.js', '.vue', '.json'],
alias: {
'@components': resolve('components'),
'@directives': resolve('directives'),
'@helpers': resolve('helpers'),
'@router': resolve('router'),
'@store': resolve('store'),
'@src': resolve('')
}
},
module: {
rules: [
// doc url https://vue-loader.vuejs.org/en/options.html#loaders
{
test: /\.vue$/,
loader: 'vue-loader',
options: {
loaders: {
js: 'babel-loader'
}
}
},
{
test: /\.js$/,
loader: 'babel-loader',
include: [
resolve(''),
path.resolve('node_modules/vue-color'),
path.resolve('node_modules/vue-multiselect')
],
query: {
presets:[ "env", "stage-3" , "es2015" ]
}
},
{
test: /\.(png|jpg|gif|svg)$/,
loader: 'file-loader',
exclude: /node_modules/,
options: {
name: '[name].[ext]?[hash]'
}
},
{
test: /\.less$/,
use: [{
loader: "style-loader" // creates style nodes from JS strings
}, {
loader: "css-loader" // translates CSS into CommonJS
}, {
loader: "less-loader" // compiles Less to CSS
}]
}
]
},
plugins: plugins
}