You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
67 lines
1.6 KiB
67 lines
1.6 KiB
'use strict'
|
|
|
|
process.env.BABEL_ENV = 'main'
|
|
|
|
const path = require('path')
|
|
const { dependencies } = require('../../package.json')
|
|
const webpack = require('webpack')
|
|
|
|
const MinifyPlugin = require("babel-minify-webpack-plugin")
|
|
|
|
let mainConfig = {
|
|
entry: {
|
|
main: path.join(__dirname, '../../src/main/index.ts')
|
|
},
|
|
externals: [
|
|
...Object.keys(dependencies || {})
|
|
],
|
|
module: {
|
|
rules: [
|
|
// { test: /\.ts?$/, loader: "ts-loader", exclude: /node_modules/ },
|
|
{
|
|
test: /\.js$/,
|
|
use: ['babel-loader'],
|
|
exclude: /node_modules/
|
|
},
|
|
{
|
|
test: /\.node$/,
|
|
use: 'node-loader'
|
|
}
|
|
]
|
|
},
|
|
// https://www.webpackjs.com/configuration/node/
|
|
node: {
|
|
// __dirname: process.env.NODE_ENV !== 'production', // 不转化为字符串
|
|
// __filename: process.env.NODE_ENV !== 'production' // 不转化为字符串
|
|
},
|
|
output: {
|
|
filename: 'entry.js', // [name]
|
|
libraryTarget: 'commonjs2',
|
|
path: path.join(__dirname, '../../dist/electron')
|
|
},
|
|
plugins: [
|
|
new webpack.NoEmitOnErrorsPlugin()
|
|
],
|
|
resolve: {
|
|
alias: {
|
|
"@": path.join(__dirname, "../../src/render"),
|
|
"@render": path.join(__dirname, "../../src/render"),
|
|
"@main": path.join(__dirname, "../../src/main"),
|
|
"@src": path.join(__dirname, "../../src"),
|
|
"@root": path.join(__dirname, "../../"),
|
|
},
|
|
extensions: ['.js', '.json', '.node', '.ts']
|
|
},
|
|
target: 'electron-main'
|
|
}
|
|
|
|
/**
|
|
* Adjust mainConfig for production settings
|
|
*/
|
|
if (process.env.NODE_ENV === 'production') {
|
|
mainConfig.plugins.push(
|
|
new MinifyPlugin()
|
|
)
|
|
}
|
|
|
|
module.exports = mainConfig
|