forked from callstack/repack
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
74 lines (71 loc) · 1.88 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
/* eslint-disable import/no-extraneous-dependencies */
const path = require('path');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
/**
* Webpack config for building client dashboard including debugger UI.
*/
const mode = process.env.NODE_ENV || 'development';
module.exports = {
mode,
devtool: mode === 'development' ? 'cheap-module-source-map' : 'source-map',
context: __dirname,
entry: './src/client/index.js',
output: {
path: path.join(__dirname, 'dist/client'),
clean: true,
filename: 'static/js/[name].[contenthash:8].js',
publicPath: '/debugger-ui/',
},
module: {
rules: [
{
test: /debuggerWorker.js$/,
use: { loader: 'worker-loader' },
},
{
test: /\.(ts|js)x?$/,
loader: 'babel-loader',
options: {
babelrc: false,
configFile: require.resolve('./babel.config.js'),
},
},
{
test: [/\.bmp$/, /\.gif$/, /\.jpe?g$/, /\.png$/],
loader: require.resolve('url-loader'),
options: {
limit: 10000,
name: 'static/media/[name].[hash:8].[ext]',
},
},
{
test: /\.css$/,
use: [
{
loader: MiniCssExtractPlugin.loader,
},
{
loader: 'css-loader',
options: { importLoaders: 1 },
},
],
sideEffects: true,
},
],
},
plugins: [
new HtmlWebpackPlugin({
inject: true,
template: path.join(__dirname, './public/index.html'),
}),
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(mode),
}),
new MiniCssExtractPlugin({
filename: 'static/css/[name].[contenthash:8].css',
chunkFilename: 'static/css/[name].[contenthash:8].chunk.css',
}),
],
};