-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwebpack.config.js
98 lines (97 loc) · 2.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
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
96
97
98
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const webpack = require('webpack');
const VueLoaderPlugin = require('vue-loader/lib/plugin');
module.exports = {
entry: {
main: './src/main.js',
snow: './src/third/snow.js',
turntable: './src/third/GB-canvas-turntable.js'
},
output: {
filename: '[name].bundle.js',
path: path.resolve(__dirname, 'dist')
},
module: {
rules: [
// vue文件加载器
{
test: /\.vue$/,
use: [
'vue-loader'
]
},
// css loader
{
test: /\.css$/,
use: [
'style-loader',
'css-loader'
]
},
// 图片loader
{
test: /\.(png|svg|jpg|gif)$/,
use: [
'file-loader'
]
},
// 字体loader,my-font.woff,此处没有引入字体
{
test: /\.(woff|woff2|eot|ttf|otf)$/,
use: [
'file-loader'
]
},
{
test: /\.mp3$/,
use: [
'url-loader'
]
},
// es6
{
test: /\.m?js$/,
exclude: /(node_modules|bower_components)/,
use: {
loader: 'babel-loader',
options: {
presets: ['env']
}
}
}
]
},
plugins: [
new HtmlWebpackPlugin({
title: 'webpack demo',
filename: 'index.html', // 新创建的html的名称
template: './public/index.html', // 根据这个路径下的html为模板来创建新的html
// chunks和entry对应
chunks: [
'snow',
'turntable',
'main'
]
}),
new webpack.HotModuleReplacementPlugin(),
new VueLoaderPlugin(),
new webpack.ProvidePlugin({
$: 'jquery',
jQuery: 'jquery'
}),
new webpack.ProvidePlugin({
Vue: ['vue/dist/vue.esm.js', 'default']
})
],
mode: 'development',
// 开发工具,浏览器中可以搜索到实际文件名
devtool: 'source-map',
// 模块热替换
devServer: {
contentBase: './dist',
host: '0.0.0.0',
port: 9000,
hot: true
}
};