-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
93 lines (79 loc) · 2.03 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
const
path = require('path'),
htmlWebpackPlugin = require('html-webpack-plugin'),
webpack = require('webpack')
const isProd = process.env.NODE_ENV === 'production' ? true : false
const option = {
entry: [
'bootstrap/dist/css/bootstrap.min.css',
'./src/ui/index.less',
'./src/ui/index.ts'
],
output: {
path: path.resolve('dist'),
filename: 'main.js'
},
devServer: {
hot: true,
contentBase: '.'
},
resolve: {
alias: {
vue: 'vue/dist/vue.common.js'
},
extensions: ['.ts', '.js']
},
devtool: isProd ? false : 'source-map',
module: {
rules: [
// {
// test: /\.js$/,
// use: ['babel-loader'],
// exclude: /node_modules/
// },
{
test: /\.(vert|frag)$/,
use: ['raw-loader']
},
{
test: /\.(jpg|png|svg)$/,
use: ['url-loader']
},
{
test: /\.less$/,
use: ['style-loader', 'css-loader', 'less-loader']
},
{
test: /\.css$/,
use: ['style-loader', 'css-loader']
},
{
test: /\.ts$/,
use: ['ts-loader'],
exclude: /node_modules/
}
]
},
plugins: [
new htmlWebpackPlugin({
template: './src/ui/index.html',
hash: true,
filename: 'index.html',
inject: 'body',
minify: {
collapseWhitespace: true
}
}),
// isProd ? new copyWebpackPlugin([
// {from: 'static/textures', to: 'static/textures'}
// ]) : null,
],
mode: isProd ? 'production' : 'development'
}
if (!isProd) {
option.plugins.push(
new webpack.NamedModulesPlugin(),
new webpack.HotModuleReplacementPlugin()
)
}
module.exports = option