-
Notifications
You must be signed in to change notification settings - Fork 1
/
webpack.config.js
74 lines (71 loc) · 1.67 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
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const path = require('path');
// 连接地址
const join = function(url){
return path.join(__dirname, url);
};
// 绝对地址
const resolve = function(url){
return path.resolve(__dirname, url);
};
module.exports = {
entry: {
app: join('main.js'),
},
output: {
path: resolve('dist'),
filename: '[name].js',
publicPath: '/',
},
resolve: {
extensions: ['.js','.css'],
alias: {
basePath: resolve('utils/util'),
}
},
devServer: {
contentBase: false, //静态资源
port: 8081, //端口
host: 'localhost',
open: true, //是否自动打开浏览器啊
inline: true,
overlay: true,
stats: 'errors-only'
},
module: {
rules: [
{
test: /\.js$/,
loader: 'babel-loader',
exclude: [resolve('./node_modules')]
},
{
test: /\.css$/,
use: [ 'style-loader', 'css-loader' ],
},
{
test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
loader: 'url-loader',
}
]
},
plugins: [
new webpack.ProvidePlugin({
THREE:'three',
BASEPATH: 'basePath',
}),
new HtmlWebpackPlugin({
filename: 'index.html',
template: 'index.html',
inject: true
}),
// 静态资源
new CopyWebpackPlugin([
{ from: join('assets/image'), to: join('dist/assets/image/') },
{ from: join('models'), to: join('dist/models/') },
{ from: join('json'), to: join('dist/json/') }
])
],
}