-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathwebpack.config.js
104 lines (100 loc) · 2.42 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
94
95
96
97
98
99
100
101
102
103
104
// const path = require('path');
// const HtmlWebpackPlugin = require('html-webpack-plugin');
const { CleanWebpackPlugin } = require('clean-webpack-plugin')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
const WebpackShellPluginNext = require('webpack-shell-plugin-next')
const gameRoot = process.cwd()
// the path(s) that should be cleaned
const pathsToClean = [
'build'
]
// the clean options to use
const cleanOptions = {
verbose: true,
dry: false
}
const config = {
// bundle javascript
entry: `${gameRoot}/src/index.js`,
output: {
path: `${gameRoot}/build`,
filename: 'struktogramm.js'
// path: path.resolve(__dirname, "build"),
// publicPath: "${game_root}/build"
},
resolve: { symlinks: false },
module: {
rules: [
{
test: /\.js$/,
exclude: ['/node_modules/',
'/build_tools/'
],
use: {
loader: 'babel-loader'
}
},
{
test: /\.scss$/,
use: [
MiniCssExtractPlugin.loader,
{
loader: 'css-loader',
options: {
// modules: true,
// sourceMap: true,
// importLoaders: 1
}
},
'sass-loader'
]
},
{
test: /\.svg$/,
use: {
loader: 'svg-url-loader',
options: {
stripdeclarations: true
}
}
}
]
},
plugins: [
new WebpackShellPluginNext({
onBuildStart: {
scripts: ['node ./build_tools/prepareSvg.js'],
blocking: true,
parallel: false
}
}),
new CleanWebpackPlugin({ pathsToClean, cleanOptions }),
new MiniCssExtractPlugin({
filename: 'struktogramm.css',
chunkFilename: '[name].css'
}),
new HtmlWebpackPlugin({
title: 'Struktog.',
template: './src/index.html',
meta: {
viewport: 'width=device-width, initial-scale=1, user-scalable=no',
'msapplication-TileColor': '#2d89ef',
'theme-color': '#ffffff'
}
})
],
devServer: {
port: 8081,
contentBase: './src',
watchOptions: {
poll: true
},
open: true
}
}
module.exports = (env, argv) => {
if (!argv || !argv.mode) { config.mode = 'development' }
if (!argv || !argv.mode || argv.mode === 'development') { config.devtool = 'source-map' }
return config
}