Skip to content

Commit

Permalink
fix: electron get .env param
Browse files Browse the repository at this point in the history
  • Loading branch information
ahwei committed Oct 19, 2022
1 parent 351740b commit 215958e
Showing 1 changed file with 31 additions and 21 deletions.
52 changes: 31 additions & 21 deletions webpack.electron.babel.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import path from 'path';
import CopyPlugin from 'copy-webpack-plugin';
import CopyPlugin from 'copy-webpack-plugin'
import path from 'path'
const Dotenv = require('dotenv-webpack')

export default {
resolve: {
Expand All @@ -10,32 +11,41 @@ export default {
target: 'electron-main',
stats: 'errors-only',
module: {
rules: [{
test: /\.(js|ts|tsx)$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
rules: [
{
test: /\.(js|ts|tsx)$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
},
},
}, {
test: /\.svg$/,
issuer: /\.[jt]sx?$/,
use: ['@svgr/webpack', 'url-loader'],
}, {
test: /\.(gif|png|jpe?g|ico|icns)$/i,
type: 'asset/resource',
}],
{
test: /\.svg$/,
issuer: /\.[jt]sx?$/,
use: ['@svgr/webpack', 'url-loader'],
},
{
test: /\.(gif|png|jpe?g|ico|icns)$/i,
type: 'asset/resource',
},
],
},
output: {
path: path.resolve(__dirname, './build/electron'),
filename: '[name].js',
hashFunction: "sha256",
hashFunction: 'sha256',
},
plugins: [
new Dotenv({
path: './.env',
}),
new CopyPlugin({
patterns: [{
from: path.resolve(__dirname, './src/electron/preload.js'),
to: path.resolve(__dirname, './build/electron'),
}],
patterns: [
{
from: path.resolve(__dirname, './src/electron/preload.js'),
to: path.resolve(__dirname, './build/electron'),
},
],
}),
],
};
}

0 comments on commit 215958e

Please sign in to comment.