123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- '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")
- const CopyWebpackPlugin = require('copy-webpack-plugin')
- let mainConfig = {
- entry: {
- main: path.join(__dirname, '../src/main/index.js')
- },
- externals: [
- ...Object.keys(dependencies || {})
- ],
- module: {
- rules: [
- {
- test: /\.js$/,
- use: 'babel-loader',
- exclude: /node_modules/
- },
- {
- test: /\.node$/,
- use: 'node-loader'
- }
- ]
- },
- node: {
- __dirname: process.env.NODE_ENV !== 'production',
- __filename: process.env.NODE_ENV !== 'production'
- },
- output: {
- filename: '[name].js',
- libraryTarget: 'commonjs2',
- path: path.join(__dirname, '../dist/electron')
- },
- plugins: [
- new webpack.NoEmitOnErrorsPlugin(),
- new CopyWebpackPlugin([
- {
- from: path.resolve(__dirname, '../static'),
- to: 'static',
- ignore: ['.*']
- }
- ])
- ],
- resolve: {
- extensions: ['.js', '.json', '.node'],
- modules: [path.resolve('node_modules'), 'node_modules'],
- },
- target: 'electron-main',
- }
- /**
- * Adjust mainConfig for development settings
- */
- if (process.env.NODE_ENV !== 'production') {
- mainConfig.plugins.push(
- new webpack.DefinePlugin({
- '__static': `"${path.join(__dirname, '../static').replace(/\\/g, '\\\\')}"`
- })
- )
- }
- /**
- * Adjust mainConfig for production settings
- */
- if (process.env.NODE_ENV === 'production') {
- mainConfig.plugins.push(
- new MinifyPlugin(),
- new webpack.DefinePlugin({
- 'process.env.NODE_ENV': '"production"'
- })
- )
- }
- module.exports = mainConfig
|