-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
82 lines (79 loc) · 2.17 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
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const VueLoaderPlugin = require('vue-loader/lib/plugin');
const TEMPLATE_PATH = path.join(__dirname, './index.html');
const SRC_PATH = path.join(__dirname, './src');
const STATIC_PATH = path.join(__dirname, './dist');
let webpackConfig = {
mode: 'development',
entry: { index: path.join(SRC_PATH, '/index.js') },
output: {
path: STATIC_PATH,
filename: '[name].[hash].js'
},
plugins: [
new HtmlWebpackPlugin({
title: 'ViteJS Demo',
template: TEMPLATE_PATH
}),
new VueLoaderPlugin()
],
optimization: {
splitChunks: {
cacheGroups: {
vendors: {
test: /[\\/]node_modules[\\/]/,
name: 'vendor',
chunks: 'all'
},
default: {
minChunks: 2,
priority: -20,
reuseExistingChunk: true
}
}
}
},
module: {
rules: [
{
test: /\.vue$/,
use: [{ loader: 'vue-loader' }]
},
{
test: /\.(svg|png|jpg|gif)$/,
loader: 'url-loader',
query: {
// 10KB
limit: 10 * 1024
}
}, {
test: /\.js$/,
use: {
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env']
}
}
}, {
test: /(\.scss$|\.css$|\.sass$)/,
use: [
{ loader: 'style-loader' },
{ loader: 'css-loader' },
{ loader: 'sass-loader' }
]
} ]
},
resolve: {
alias: {
vue: 'vue/dist/vue.js',
src: SRC_PATH
},
extensions: [ '.js', '.scss', '.vue', '.json' ]
},
devServer: {
quiet: false,
port: 8080,
}
};
module.exports = webpackConfig;