-
Notifications
You must be signed in to change notification settings - Fork 14
/
webpack.config.js
89 lines (73 loc) · 2.15 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
const path = require('path')
const webpack = require('webpack')
const SpritesheetPlugin = require('./webpack/SpritesheetPlugin')
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const AudioSprite = require("audiosprite-loader");
const TerserPlugin = require('terser-webpack-plugin');
// var stylusLoader = ExtractTextPlugin.extract("style-loader", "css-loader!stylus-loader");
const stylusLoader = ExtractTextPlugin.extract({ fallback: "style-loader", use: ["css-loader", "stylus-loader"] })
const mode = process.env.NODE_ENV || "development";
console.log("PRODUCTION?", (mode === "production"));
module.exports = {
mode,
entry: {
bundle: './client/main.js',
dungeon_viewer: './client/dungeon_viewer.js'
},
output: {
path: path.join(__dirname, 'public'),
// filename: 'bundle.js'
},
devtool: 'source-map',
devServer: {
host: '0.0.0.0',
contentBase: './public',
},
module: {
rules: [
{
test: /.*\.jsx?$/,
exclude: /(node_modules|bower_components)/,
loader: 'babel-loader',
},
{ test: /\.styl$/, loader: stylusLoader },
{ test: /\.(woff|woff2|eot|ttf|svg|jpg|png)$/, loader: 'file-loader?limit=1024&name=[name].[ext]' },
{ test: /\.(wav|ogg|mp3|aif)$/, loader: AudioSprite.loader() }
],
},
plugins: [
new AudioSprite.Plugin(),
new webpack.ProvidePlugin({
THREE: "three",
Tweener: "tweener",
App: [__dirname + "/client/core/App", "default"],
ResourceManager: [__dirname + '/client/resource/manager', 'default'],
config: __dirname + '/client/config'
}),
new ExtractTextPlugin("style.css"),
new SpritesheetPlugin(__dirname + "/public/images/sprites/*.png", {
format: 'json',
path: "public/images",
powerOfTwo: true,
padding: 1
})
],
optimization: {
minimize: (mode === "production"),
minimizer: [
new TerserPlugin({
terserOptions: {
compress: {},
mangle: true,
toplevel: true,
output: {
comments: false
}
}
})
],
},
resolve: {
extensions: ['.js', '.jsx', '.json']
}
}