-
Notifications
You must be signed in to change notification settings - Fork 414
/
webpack.config.js
84 lines (82 loc) · 1.92 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
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const { join } = require('path'); // eslint-disable-line import/no-extraneous-dependencies
const HtmlWebpackPlugin = require('html-webpack-plugin');
const { WYWinJSDebugPlugin } = require('@wyw-in-js/webpack-loader');
const dev = process.env.NODE_ENV !== 'production';
module.exports = {
mode: dev ? 'development' : 'production',
devtool: 'source-map',
entry: {
app: './src/index',
},
output: {
path: join(__dirname, 'dist'),
filename: '[name].bundle.js',
},
optimization: {
emitOnErrors: false,
},
plugins: [
new WYWinJSDebugPlugin({
dir: 'wyw-debug',
print: true,
}),
new MiniCssExtractPlugin({ filename: 'styles.css' }),
new HtmlWebpackPlugin({
title: 'Linaria – zero-runtime CSS in JS library',
templateContent: `
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<div id="root"></div>
</body>
</html>
`,
}),
],
resolve: {
extensions: ['.js', '.jsx'],
},
module: {
rules: [
{
test: /\.jsx?$/,
exclude: /node_modules/,
use: [
{ loader: 'babel-loader' },
{
loader: require.resolve('@wyw-in-js/webpack-loader'),
options: { sourceMap: dev },
},
],
},
{
test: /\.css$/,
use: [
'css-hot-loader',
MiniCssExtractPlugin.loader,
{
loader: 'css-loader',
options: { sourceMap: dev },
},
],
},
{
test: /\.(png|jpg|gif|svg)$/,
type: 'asset/resource',
},
],
},
devServer: {
static: {
directory: join(__dirname, 'dist'),
},
hot: true,
historyApiFallback: {
index: 'index.html',
},
},
};