Repo created
This commit is contained in:
parent
f3a6b3a320
commit
f954c78789
614 changed files with 135712 additions and 2 deletions
72
_scripts/webpack.main.config.js
Normal file
72
_scripts/webpack.main.config.js
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
const path = require('path')
|
||||
const webpack = require('webpack')
|
||||
const CopyWebpackPlugin = require('copy-webpack-plugin')
|
||||
const JsonMinimizerPlugin = require('json-minimizer-webpack-plugin')
|
||||
|
||||
const isDevMode = process.env.NODE_ENV === 'development'
|
||||
|
||||
const config = {
|
||||
name: 'main',
|
||||
mode: process.env.NODE_ENV,
|
||||
devtool: isDevMode ? 'eval-cheap-module-source-map' : false,
|
||||
entry: {
|
||||
main: path.join(__dirname, '../src/main/index.js'),
|
||||
},
|
||||
module: {
|
||||
rules: [
|
||||
{
|
||||
test: /\.js$/,
|
||||
use: 'babel-loader',
|
||||
exclude: /node_modules/,
|
||||
},
|
||||
{
|
||||
resource: path.resolve(__dirname, '../node_modules/mime-db/db.json'),
|
||||
use: path.join(__dirname, 'mime-db-shrinking-loader.js')
|
||||
}
|
||||
],
|
||||
},
|
||||
// webpack defaults to only optimising the production builds, so having this here is fine
|
||||
optimization: {
|
||||
minimizer: [
|
||||
'...', // extend webpack's list instead of overwriting it
|
||||
new JsonMinimizerPlugin({
|
||||
exclude: /\/locales\/.*\.json/
|
||||
})
|
||||
]
|
||||
},
|
||||
node: {
|
||||
__dirname: isDevMode,
|
||||
__filename: isDevMode
|
||||
},
|
||||
plugins: [
|
||||
new webpack.DefinePlugin({
|
||||
'process.env.IS_ELECTRON_MAIN': true
|
||||
})
|
||||
],
|
||||
output: {
|
||||
filename: '[name].js',
|
||||
libraryTarget: 'commonjs2',
|
||||
path: path.join(__dirname, '../dist'),
|
||||
publicPath: ''
|
||||
},
|
||||
target: 'electron-main',
|
||||
}
|
||||
|
||||
if (!isDevMode) {
|
||||
config.plugins.push(
|
||||
new CopyWebpackPlugin({
|
||||
patterns: [
|
||||
{
|
||||
from: path.join(__dirname, '../static'),
|
||||
to: path.join(__dirname, '../dist/static'),
|
||||
globOptions: {
|
||||
dot: true,
|
||||
ignore: ['**/.*', '**/locales/**', '**/pwabuilder-sw.js', '**/manifest.json', '**/dashFiles/**', '**/storyboards/**'],
|
||||
},
|
||||
},
|
||||
]
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
module.exports = config
|
||||
Loading…
Add table
Add a link
Reference in a new issue