-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
58 lines (57 loc) · 1.62 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
// webpack.config.js
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
// 最新的 vue-loader 中,VueLoaderPlugin 插件的位置有所改变
const { VueLoaderPlugin } = require('vue-loader/dist/index');
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
module.exports = {
mode: 'development', // 环境模式
entry: path.resolve(__dirname, './example/vue/main.js'), // 打包入口
output: {
path: path.resolve(__dirname, './example/vue/dist'), // 打包出口
filename: 'js/[name].js', // 打包完的静态资源文件名
},
resolve: {
alias: {
'@': path.resolve(__dirname, 'src'),
},
},
stats: 'none',
devServer: {
compress: true, // 压缩
port: 8083,
hot: true, // 启用热更新
client: {
logging: 'error',
overlay: true,
progress: true,
},
},
module: {
rules: [
{
test: /\.vue$/,
use: ['vue-loader'],
},
{
test: /\.css$/,
use: ['style-loader', 'css-loader'],
},
{
test: /\.js$/,
exclude: /node_modules/, // 不编译node_modules下的文件
loader: 'babel-loader',
},
],
},
plugins: [
new CleanWebpackPlugin(),
new HtmlWebpackPlugin({
template: path.resolve(__dirname, './example/vue/public/index.html'), // 我们要使用的 html 模板地址
filename: 'index.html', // 打包后输出的文件名
title: 'test', // index.html 模板内,通过 <%= htmlWebpackPlugin.options.title %> 拿到的变量
}),
// 添加 VueLoaderPlugin 插件
new VueLoaderPlugin(),
],
};