-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
68 lines (66 loc) · 1.47 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
//引入插件
const path = require('path');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
//引入导出css插件
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const {VueLoaderPlugin} = require('vue-loader');
const config = {
mode: 'development',
entry:'./src/main.js',
//服务
devServer:{
//启用 webpack 的模块热替换特性
hot:true
},
module:{
rules:[
{
test:/\.vue$/,
loader:'vue-loader'
},
{//ES6
test:/\.js$/,
loader:'babel-loader',
exclude:path.resolve(__dirname,'node_modules'),
query:{//若在package.json中定义了这个presets,则这边可以删掉
presets:['es2015']
}
},
{//CSS
test:/\.css/,
use:ExtractTextPlugin.extract({
use:['css-loader']
})
},
{//Sass
test:/\.scss/,
use:ExtractTextPlugin.extract({
fallback:"style-loader",
use:['css-loader','sass-loader']
},)
}
]
},
//从Compiler版本修改为Runtime版本
resolve: {
alias: { 'vue': 'vue/dist/vue.js' }
},
plugins:[
new HtmlWebpackPlugin({
filename:'index.html',
template:'./index.html',
hash:true
}),
//将css单独打包插件
new ExtractTextPlugin({
filename:"bundle.css"//制定编译后的文件名称
}),
new VueLoaderPlugin()
],
output:{
filename:'bundle.js',
path:path.resolve(__dirname,'dist')
}
}
module.exports = config;