-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
97 lines (94 loc) · 2.25 KB
/
webpack.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
const path = require('path')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const RemovePlugin = require('remove-files-webpack-plugin')
const CopyPlugin = require('copy-webpack-plugin')
const webpack = require('webpack')
const srcDir = path.resolve(__dirname, 'src/app')
const outputDir = path.resolve(__dirname, 'dist')
const ffmpegPath = path.join('node_modules', 'ffmpeg-static')
const ffprobePath = path.join('node_modules', 'ffprobe-static/bin/win32/x64')
const commonConfig = {
output: {
path: outputDir,
filename: '[name].js',
},
resolve: {
extensions: ['.js', '.jsx', '.ts', '.tsx'],
},
externals: {
deasync: 'deasync',
},
module: {
rules: [
{
test: [/\.js$/, /\.tsx?$/],
exclude: /node_modules/,
use: {
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env', '@babel/preset-typescript', ['@babel/preset-react', { runtime: 'automatic' }]],
},
},
},
{
test: /\.css$/i,
use: ['style-loader', 'css-loader', 'postcss-loader'],
},
],
},
}
module.exports = [
Object.assign(
{
target: 'electron-main',
entry: { main: './src/app/js/main.ts' },
node: {
__dirname: false,
},
plugins: [
new webpack.DefinePlugin({
'process.env.FLUENTFFMPEG_COV': false,
}),
new CopyPlugin({
patterns: [
{
from: path.resolve(ffmpegPath, 'ffmpeg.exe'),
to: outputDir,
},
{
from: path.resolve(ffprobePath, 'ffprobe.exe'),
to: outputDir,
},
],
}),
],
},
commonConfig
),
Object.assign(
{
target: 'electron-preload',
entry: { preload: './src/app/js/preload.ts' },
},
commonConfig
),
Object.assign(
{
target: 'electron-renderer',
entry: { gui: './src/app/js/gui.tsx' },
plugins: [
new RemovePlugin({
before: {
log: false,
include: [outputDir],
},
}),
new HtmlWebpackPlugin({
template: path.join(srcDir, 'index.html'),
inject: 'body',
}),
],
},
commonConfig
),
]