-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
60 lines (55 loc) · 1.84 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
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
// Base config that applies to either development or production mode.
const config = {
entry: './src/index.js',
output: {
// Compile the source files into a bundle.
filename: 'bundle.js',
path: path.resolve(__dirname, 'dist'),
clean: true,
},
// Enable webpack-dev-server to get hot refresh of the app.
devServer: {
static: './build',
},
module: {
rules: [
{
// Load CSS files. They can be imported into JS files.
test: /\.css$/i,
use: ['style-loader', 'css-loader'],
},
],
},
plugins: [
// Generate the HTML index page based on our template.
// This will output the same index page with the bundle we
// created above added in a script tag.
new HtmlWebpackPlugin({
template: 'src/index.html',
favicon: 'src/ico.png',
}),
],
};
module.exports = (env, argv) => {
if (argv.mode === 'development') {
// Set the output path to the `build` directory
// so we don't clobber production builds.
config.output.path = path.resolve(__dirname, 'build');
// Generate source maps for our code for easier debugging.
// Not suitable for production builds. If you want source maps in
// production, choose a different one from https://webpack.js.org/configuration/devtool
config.devtool = 'eval-cheap-module-source-map';
// Include the source maps for Blockly for easier debugging Blockly code.
config.module.rules.push({
test: /(blockly\/.*\.js)$/,
use: [require.resolve('source-map-loader')],
enforce: 'pre',
});
// Ignore spurious warnings from source-map-loader
// It can't find source maps for some Closure modules and that is expected
config.ignoreWarnings = [/Failed to parse source map/];
}
return config;
};