加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
webpack.config.main.prod.js 1.74 KB
一键复制 编辑 原始数据 按行查看 历史
Fabrizio 提交于 2019-03-20 20:25 . including custom protos resolution (#55)
/**
* Webpack config for production electron main process
*/
const path = require('path');
const webpack = require('webpack');
const merge = require('webpack-merge');
const TerserPlugin = require('terser-webpack-plugin');
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
const baseConfig = require('./webpack.config.base');
const CheckNodeEnv = require('./internals/scripts/CheckNodeEnv');
CheckNodeEnv('production');
module.exports = merge.smart(baseConfig, {
devtool: 'source-map',
mode: 'production',
target: 'electron-main',
entry: './app/main.dev',
output: {
path: __dirname,
filename: './app/main.prod.js'
},
optimization: {
minimizer: [
new TerserPlugin({
parallel: true,
sourceMap: true
})
]
},
plugins: [
new BundleAnalyzerPlugin({
analyzerMode:
process.env.OPEN_ANALYZER === 'true' ? 'server' : 'disabled',
openAnalyzer: process.env.OPEN_ANALYZER === 'true'
}),
/**
* Create global constants which can be configured at compile time.
*
* Useful for allowing different behaviour between development builds and
* release builds
*
* NODE_ENV should be production so that modules do not perform certain
* development checks
*/
new webpack.EnvironmentPlugin({
NODE_ENV: 'production',
DEBUG_PROD: 'false'
}),
new webpack.DefinePlugin({
__static: `process.resourcesPath + "/static"`
}),
],
/**
* Disables webpack processing of __dirname and __filename.
* If you run the bundle in node.js it falls back to these values of node.js.
* https://github.com/webpack/webpack/issues/2010
*/
externals: ['grpc'],
node: {
__dirname: false,
__filename: false
}
});
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化