-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
97 lines (91 loc) · 2.16 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
const path = require('path')
const ExtractTextPlugin = require('extract-text-webpack-plugin')
const FaviconsPlugin = require('favicons-webpack-plugin')
const HtmlPlugin = require('html-webpack-plugin')
const SERVER_PORT = 9000
const DIST_FOLDER = 'dist'
const SRC_FOLDER = 'automaton'
function getPath(filePath) {
return path.resolve(__dirname, filePath)
}
module.exports = (env, options) => {
const isProduction = options.mode === 'production'
const plugins = [
new HtmlPlugin({
filename: 'index.html',
hash: true,
inject: 'body',
template: getPath(`./${SRC_FOLDER}/index.html`),
minify: {
collapseWhitespace: true,
minifyJS: true,
removeComments: true,
},
}),
new FaviconsPlugin({
logo: getPath(`./${SRC_FOLDER}/favicon.png`),
persistentCache: false,
prefix: '',
icons: {
android: false,
appleIcon: false,
appleStartup: false,
firefox: false,
},
}),
new ExtractTextPlugin({
filename: '[name].css',
}),
]
return {
entry: getPath(`./${SRC_FOLDER}/scripts/index.js`),
output: {
path: getPath(`./${DIST_FOLDER}/play`),
filename: '[name].js',
},
resolve: {
modules: [
'node_modules',
],
alias: {
'osc-js': getPath('./node_modules/osc-js/lib/osc.browser.js'),
},
},
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
},
},
{
test: /\.scss$/,
exclude: /node_modules/,
use: ExtractTextPlugin.extract({
fallback: 'style-loader',
use: [
{
loader: 'css-loader',
options: {
minimize: isProduction,
sourceMap: false,
},
},
{
loader: 'sass-loader',
},
],
}),
},
],
},
devtool: isProduction ? false : 'source-map',
devServer: {
compress: true,
port: SERVER_PORT,
},
plugins,
}
}