-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathwebpack.config.js
More file actions
89 lines (86 loc) · 2.1 KB
/
webpack.config.js
File metadata and controls
89 lines (86 loc) · 2.1 KB
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'),
webpack = require('webpack'),
HtmlWebpackPlugin = require('html-webpack-plugin'),
MiniCssExtractPlugin = require('mini-css-extract-plugin');
/* DIRS */
const nm = path.resolve(__dirname, 'node_modules'),
srcPath = path.resolve(__dirname, 'src'),
assetsPath = path.resolve(__dirname, 'assets'),
stylesPath = path.resolve(__dirname, 'assets', 'styles'),
fontsPath = path.resolve(__dirname, 'assets', 'fonts'),
imagesPath = path.resolve(__dirname, 'assets', 'images'),
videosPath = path.resolve(__dirname, 'assets', 'videos');
module.exports = {
resolve: {
modules: [
nm,
srcPath,
assetsPath,
stylesPath,
fontsPath,
imagesPath,
videosPath
]
},
entry: {
game: path.join(srcPath, 'game.js'),
vendor: ['phaser']
},
plugins: [
new webpack.DefinePlugin({
'CANVAS_RENDERER': JSON.stringify(true),
'WEBGL_RENDERER': JSON.stringify(true)
}),
new HtmlWebpackPlugin({
template: path.resolve(srcPath, 'index.html'),
title: "Phaser3 Heroku ready"
}),
new MiniCssExtractPlugin({
filename: "[name].css",
chunkFilename: "[id].css"
})
],
module: {
rules: [
{
/* babel */
test: /\.js$/,
loader: 'babel-loader',
include: srcPath,
exclude: nm,
options: {
compact: true
}
},
{
/* css */
test: /\.css$/,
use: [
{
loader: MiniCssExtractPlugin.loader,
options: {
// you can specify a publicPath here
// by default it use publicPath in webpackOptions.output
publicPath: '/css/'
}
},
"css-loader"
]
},
{
/* images */
test: /\.(jpe?g|png|gif)$/,
loader: 'file-loader',
include: [ fontsPath, imagesPath, videosPath ],
exclude: nm,
options: {
name: '[path][name].[ext]'
}
},
{
test: [ /\.vert$/, /\.frag$/ ],
use: 'raw-loader'
}
]
}
}