-
Notifications
You must be signed in to change notification settings - Fork 86
/
webpack.config.js
82 lines (79 loc) · 1.94 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 HtmlWebpackPlugin = require('html-webpack-plugin')
const { CleanWebpackPlugin } = require('clean-webpack-plugin')
const CopyWebpackPlugin = require('copy-webpack-plugin')
const openBrowser = process.argv[3] === '--silence' ? false : true
module.exports = [
{
mode: 'development',
context: __dirname,
entry: {
index: [
'./src/script/lib/pixi.js',
'./src/script/lib/gsap/TweenMax.js',
'./src/script/snake.es6'
]
},
output: {
path: __dirname + '/dist/',
filename: './script/[name]-[hash:16].js'
},
module: {
rules: [
{
test: function (src) {
if (
src.indexOf('script/lib/pixi.js') >= 0 ||
src.indexOf('script/lib/gsap/TweenMax.js') >= 0
) {
return false
}
if (/\.es6$|\.js$/.test(src)) {
return true
}
},
use: [
{
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env']
}
}
]
}
]
},
plugins: [
new CleanWebpackPlugin(),
new HtmlWebpackPlugin({
title: 'H5小游戏100例: 贪吃蛇',
template: './src/snake.html',
filename: './dist/snake.html',
inject: true
}),
new CopyWebpackPlugin([
{
from: './src/css/snake.css',
to: './dist/css/snake.css'
},
{
from: './src/images/[email protected]',
to: './dist/images/[email protected]'
},
{
from: './src/images/[email protected]',
to: './dist/images/[email protected]'
},
{
from: './src/images/[email protected]',
to: './dist/images/[email protected]'
}
]),
],
devServer: {
contentBase: './dist/',
open: openBrowser,
openPage: './dist/snake.html'
},
watch: true
}
]