-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.renderer.development.js
76 lines (71 loc) · 2.1 KB
/
webpack.renderer.development.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
const { merge } = require('webpack-merge');
const cssModulesScopedName = '[path]___[name]__[local]___[hash:base64:5]';
const createElectronReloadWebpackPlugin = require('electron-reload-webpack-plugin');
const common = require('./webpack.renderer.common.js');
const ElectronReloadWebpackPlugin = createElectronReloadWebpackPlugin({
// Path to `package.json` file with main field set to main process file path, or just main process file path
path: './',
// or just `path: './'`,
// Other 'electron-connect' options
logLevel: 0,
});
module.exports = merge(common, {
mode: 'development',
devtool: 'inline-source-map',
plugins: [ElectronReloadWebpackPlugin('electron-renderer')],
module: {
rules: [
{
test: /\.tsx?$/,
exclude: [/node_modules/],
use: [
{
loader: 'babel-loader',
options: {
plugins: [
// 3) .jsx => .js
'transform-react-jsx',
// 2) styleName in .jsx => className in .jsx
['react-css-modules', { generateScopedName: cssModulesScopedName }],
],
},
},
// 1) .ts => .js, .tsx => .jsx
{
loader: 'ts-loader',
options: {
configFile: 'tsconfig.renderer.development.json',
},
},
],
},
{
enforce: 'pre',
test: /\.js$/,
loader: 'source-map-loader',
},
{
test: /\.css$/,
use: [
// import .css in .js
'style-loader',
{
/**
* Must use css-loader@3 because hash generator of css-loader@4 is different from that of 'react-css-modules'
* See https://github.com/webpack-contrib/css-loader/issues/877
*/
// Apply css modules
loader: 'css-loader',
options: {
modules: {
localIdentName: cssModulesScopedName,
},
importLoaders: 1,
sourceMap: true,
},
},
],
},
],
},
});