-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
86 lines (82 loc) · 2.26 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
const path = require('path')
const VueLoader = require('vue-loader/lib/plugin')
const ExtractCSS = require('mini-css-extract-plugin')
const minify = require('babel-minify-webpack-plugin')
const VueToHTML = require('webpack-plugin-vue-to-html')
const isDev = process.env.NODE_ENV === 'development';
const isProd = process.env.NODE_ENV === 'production';
const configure = {
entry: VueToHTML.entry,
output: {
filename: 'js/[name].js',
libraryTarget: 'this',
},
resolve: {
extensions: ['.js', '.json', '.vue'],
alias: {
'@src': path.resolve(__dirname, `src`),
'@addons': path.resolve(__dirname, `src/addons`),
},
},
module: {
rules: [{
test: /\.jsx?$/,
use: 'babel-loader',
}, {
test: /\.vue$/,
use: [{
loader: 'vue-loader',
}],
}, {
test: /\.(sa|sc|c)ss$/,
use: [{
loader: ExtractCSS.loader,
options: {
publicPath: '../',
},
}, 'css-loader',
'postcss-loader',
'resolve-url-loader',
'sass-loader?outputStyle=expanded',
],
}, {
test: /\.(svg|gif|jpg|jpeg|png)$/,
use: [{
loader: `url-loader`,
options: {
limit: 1,
name: `images/[name].[ext]?[hash:8]`,
},
}],
}, {
test: /\.(woff|ttf|eot)$/,
use: [{
loader: `url-loader`,
options: {
limit: 5120,
name: `[path][name].[ext]?[hash:8]`,
},
}],
}],
},
plugins: [
new VueLoader(),
new VueToHTML({
console: isDev,
}),
new ExtractCSS({
filename: `css/[name].css?[hash:8]`,
}),
],
devServer: {
contentBase: path.join(__dirname, './dist'),
disableHostCheck: true,
compress: true,
port: '3000',
host: VueToHTML.getHost(),
},
}
if (isProd) {
configure.plugins.push(new minify());
}
module.exports = configure;