-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathwebpack.config.renderer.js
101 lines (92 loc) · 2.34 KB
/
webpack.config.renderer.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
98
99
100
101
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const webpack = require('webpack');
const merge = require('webpack-merge');
const path = require('path');
const pkg = require('read-pkg').sync();
const base = require('./webpack.config');
const cssLocalIdentName = (isDev) => {
return isDev ? '[folder]__[local]--[hash:base64:5]' : '[hash:base64:10]';
};
const config = {
target: 'electron-renderer',
entry: {
index: './src/renderer/index.jsx'
},
output: {
path: path.join(__dirname, 'dist'),
filename: 'bundle.js'
},
resolve: {
extensions: ['.css', '.ttf', 'otf', '.png', '.jpg', '.jpeg', '.gif', '.svg']
},
module: {
rules: [
{
test: /\.jsx?$/,
exclude: /node_modules/,
use: ["babel-loader"]
},
{
test: /\.css$/,
use: ExtractTextPlugin.extract({
fallback: 'style-loader',
use: [
{
loader: 'css-loader',
query: {
modules: true,
sourceMap: base.isDev,
importLoaders: 1,
localIdentName: cssLocalIdentName(base.isDev),
minimize: !base.isDev
}
},
{
loader: 'postcss-loader',
options: {
config: {
path: './postcss.config.js'
},
}
}
]
})
},
{
test: /\.(ttf|otf)$/,
exclude: /node_modules/,
loader: 'file-loader',
options: {
name: '[name].[ext]',
outputPath: './assets/fonts/'
}
},
{
test: /\.(png|jpe?g|gif|svg)$/,
exclude: /node_modules/,
loader: 'file-loader',
options: {
name: '[name].[ext]',
outputPath: './assets/images/'
}
}
]
},
plugins: [
new ExtractTextPlugin('index.css', { allChunks: true }),
new HtmlWebpackPlugin({
title: pkg.productName,
filename: './index.html',
template: './src/renderer/index.html'
})
]
};
if (base.isDev) {
config.plugins = [
...(config.plugins || []),
new webpack.NamedModulesPlugin(),
new webpack.NoEmitOnErrorsPlugin(),
];
}
module.exports = merge.smart(base.config, config);