This repository has been archived by the owner on Jan 22, 2021. It is now read-only.
forked from Azure/azure-iot-explorer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.electron.ts
60 lines (54 loc) · 2.42 KB
/
webpack.electron.ts
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
/***********************************************************
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License
**********************************************************/
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin; // tslint:disable-line: no-var-requires
import * as webpack from 'webpack';
import * as merge from 'webpack-merge';
import common from './webpack.common';
const MiniCssExtractPlugin = require('mini-css-extract-plugin'); // tslint:disable-line: no-var-requires
const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin'); // tslint:disable-line: no-var-requires
const TerserPlugin = require('terser-webpack-plugin'); // tslint:disable-line: no-var-requires
const config: webpack.Configuration = merge(common, {
mode: 'production',
module: {
rules: [
// All files with a '.ts' or '.tsx' extension will be handled by 'awesome-typescript-loader'.
{ test: /\.tsx?$/, loader: 'awesome-typescript-loader' },
{
test: /\.(scss|css)$/,
use: [
{ loader: 'style-loader'},
MiniCssExtractPlugin.loader,
{ loader: 'css-loader', options: { sourceMap: false}},
{ loader: 'sass-loader', options: {sourceMap: false}}]
}
]
},
optimization: {
minimizer: [new TerserPlugin(), new OptimizeCSSAssetsPlugin({})]
},
plugins: [
// new BundleAnalyzerPlugin(),
new MiniCssExtractPlugin({
// Options similar to the same options in webpackOptions.output
// all options are optional
chunkFilename: '[id].[hash].optimize.css',
filename: '[name].[hash].optimize.css',
ignoreOrder: false, // Enable to remove warnings about conflicting order
}),
new OptimizeCSSAssetsPlugin({
assetNameRegExp: /\.optimize\.css$/g,
canPrint: true,
cssProcessor: require('cssnano'), // tslint:disable-line
cssProcessorPluginOptions: {
preset: ['default', { discardComments: { removeAll: true } }],
},
}),
new webpack.NormalModuleReplacementPlugin(
/(.*)appConfig.ENV(\.*)/,
resource => resource.request = resource.request.replace(/ENV/, 'electron')
)
]
});
export default config;