github-desktop/app/webpack.production.ts

71 lines
2.1 KiB
TypeScript
Raw Normal View History

2018-05-05 20:14:50 +00:00
import * as common from './webpack.common'
2016-05-24 19:12:06 +00:00
2017-10-28 18:08:07 +00:00
import * as webpack from 'webpack'
import merge from 'webpack-merge'
import MiniCssExtractPlugin from 'mini-css-extract-plugin'
import { BundleAnalyzerPlugin } from 'webpack-bundle-analyzer'
2016-05-24 19:12:06 +00:00
2017-10-28 18:08:07 +00:00
const config: webpack.Configuration = {
2018-05-04 06:16:32 +00:00
mode: 'production',
2017-04-18 07:05:26 +00:00
devtool: 'source-map',
2016-05-11 16:16:32 +00:00
}
2017-04-17 20:24:00 +00:00
const mainConfig = merge({}, common.main, config)
2017-06-06 19:29:05 +00:00
const cliConfig = merge({}, common.cli, config)
const highlighterConfig = merge({}, common.highlighter, config)
2017-04-17 20:24:00 +00:00
const rendererConfig = merge({}, common.renderer, config, {
module: {
rules: [
// This will cause the compiled CSS to be output to a
// styles.css and a <link rel="stylesheet"> tag to be
// appended to the index.html HEAD at compile time
{
test: /\.(scss|css)$/,
use: [MiniCssExtractPlugin.loader, 'css-loader', 'sass-loader'],
2017-04-17 20:24:00 +00:00
},
],
},
plugins: [
// Necessary to be able to use MiniCssExtractPlugin as a loader.
2018-05-23 05:42:47 +00:00
new MiniCssExtractPlugin({ filename: 'renderer.css' }),
new BundleAnalyzerPlugin({
// this generates the static HTML file to view afterwards, rather
// than disrupting the user
analyzerMode: 'static',
openAnalyzer: false,
// we can't emit this directly to the dist directory because the
// build script immediately blows away dist after webpack is done
// compiling the source into bundles
reportFilename: 'renderer.report.html',
}),
2017-07-13 15:15:34 +00:00
],
})
2017-05-22 07:59:38 +00:00
const crashConfig = merge({}, common.crash, config, {
module: {
rules: [
// This will cause the compiled CSS to be output to a
// styles.css and a <link rel="stylesheet"> tag to be
// appended to the index.html HEAD at compile time
{
test: /\.(scss|css)$/,
use: [MiniCssExtractPlugin.loader, 'css-loader', 'sass-loader'],
2017-05-22 07:59:38 +00:00
},
],
},
plugins: [
// Necessary to be able to use MiniCssExtractPlugin as a loader.
2018-05-23 05:42:47 +00:00
new MiniCssExtractPlugin({ filename: 'crash.css' }),
2017-07-13 15:15:34 +00:00
],
2017-05-22 07:59:38 +00:00
})
2020-07-10 19:22:20 +00:00
// eslint-disable-next-line no-restricted-syntax
export default [
2017-07-13 15:15:34 +00:00
mainConfig,
rendererConfig,
crashConfig,
cliConfig,
highlighterConfig,
2017-07-13 15:15:34 +00:00
]