-
Notifications
You must be signed in to change notification settings - Fork 95
/
Copy pathwebpack.config.js
74 lines (72 loc) · 1.71 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
var openInBrowser = process.argv[3] === '--silence' ? false: true
var HtmlWebpackPlugin = require('html-webpack-plugin')
var { CleanWebpackPlugin } = require('clean-webpack-plugin')
var CopywebpackPlugin = require('copy-webpack-plugin')
module.exports = {
mode: 'development',
context: __dirname,
entry: [
'./src/script/lib/pixi.js',
'./src/script/lib/gsap/TweenMax.js',
'./src/script/Popstar.es6',
],
output: {
path: __dirname + '/dist/',
filename: '[name]-[chunkhash].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']
}
}
},
{
test: /\.png$|\.jpg$|\.jpeg$|\.gif$/i,
use: {
loader: 'file-loader',
query: {
limit: 20000,
name: '[name]-[hash:5].[ext]',
outputPath: './images/',
publicPath: '../images/'
}
},
}
]
},
plugins: [
new CleanWebpackPlugin(),
new HtmlWebpackPlugin({
title: 'H5小游戏100例: 消除星星',
template: './src/popstar.html',
filename: './dist/popstar.html'
}),
new CopywebpackPlugin([
{
from: './src/css/popstar.css',
to: './dist/css/popstar.css'
}
])
],
watch: true,
devServer: {
contentBase: './dist/',
open: openInBrowser,
openPage: './dist/popstar.html'
}
}