2018-03-07 14:28:48 +01:00
|
|
|
'use strict'
|
|
|
|
|
|
|
|
process.env.BABEL_ENV = 'renderer'
|
|
|
|
|
|
|
|
const path = require('path')
|
|
|
|
const { dependencies } = require('../package.json')
|
|
|
|
const webpack = require('webpack')
|
|
|
|
|
|
|
|
const CopyWebpackPlugin = require('copy-webpack-plugin')
|
2018-11-12 15:54:39 +01:00
|
|
|
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
|
2018-03-07 14:28:48 +01:00
|
|
|
const HtmlWebpackPlugin = require('html-webpack-plugin')
|
2018-11-12 15:54:39 +01:00
|
|
|
const { VueLoaderPlugin } = require('vue-loader')
|
2018-03-07 14:28:48 +01:00
|
|
|
|
|
|
|
let rendererConfig = {
|
|
|
|
entry: {
|
2022-07-09 17:42:09 +02:00
|
|
|
renderer: path.join(__dirname, '../src/renderer/main.ts')
|
2018-03-07 14:28:48 +01:00
|
|
|
},
|
|
|
|
module: {
|
|
|
|
rules: [
|
2022-12-19 16:47:21 +01:00
|
|
|
{
|
|
|
|
test: /\.m?js$/,
|
|
|
|
resolve: {
|
|
|
|
fullySpecified: false
|
|
|
|
}
|
|
|
|
},
|
2021-05-22 13:56:48 +02:00
|
|
|
{
|
|
|
|
test: /\.vue$/,
|
|
|
|
use: {
|
|
|
|
loader: 'vue-loader',
|
|
|
|
options: {
|
|
|
|
extractCSS: process.env.NODE_ENV === 'production',
|
2022-05-01 11:02:47 +02:00
|
|
|
esModule: true,
|
|
|
|
optimizeSSR: false
|
2021-05-22 13:56:48 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2018-11-12 15:54:39 +01:00
|
|
|
{
|
|
|
|
test: /\.scss$/,
|
2020-08-20 15:38:17 +02:00
|
|
|
use: [
|
|
|
|
'vue-style-loader',
|
|
|
|
{
|
|
|
|
loader: 'css-loader',
|
|
|
|
options: {
|
|
|
|
modules: false,
|
|
|
|
esModule: false
|
|
|
|
}
|
|
|
|
},
|
|
|
|
'sass-loader'
|
|
|
|
]
|
2018-11-12 15:54:39 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.sass$/,
|
2020-08-20 15:38:17 +02:00
|
|
|
use: [
|
|
|
|
'vue-style-loader',
|
|
|
|
|
|
|
|
{
|
|
|
|
loader: 'css-loader',
|
|
|
|
options: {
|
|
|
|
modules: false,
|
|
|
|
esModule: false
|
|
|
|
}
|
|
|
|
},
|
|
|
|
'sass-loader?indentedSyntax'
|
|
|
|
]
|
2018-11-12 15:54:39 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.less$/,
|
2020-08-20 15:38:17 +02:00
|
|
|
use: [
|
|
|
|
'vue-style-loader',
|
|
|
|
{
|
|
|
|
loader: 'css-loader',
|
|
|
|
options: {
|
|
|
|
modules: false,
|
|
|
|
esModule: false
|
|
|
|
}
|
|
|
|
},
|
|
|
|
'less-loader'
|
|
|
|
]
|
2018-11-12 15:54:39 +01:00
|
|
|
},
|
2018-03-07 14:28:48 +01:00
|
|
|
{
|
|
|
|
test: /\.css$/,
|
2020-08-20 15:38:17 +02:00
|
|
|
use: [
|
|
|
|
'vue-style-loader',
|
|
|
|
{
|
|
|
|
loader: 'css-loader',
|
|
|
|
options: {
|
|
|
|
modules: false,
|
|
|
|
esModule: false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
2018-03-07 14:28:48 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.html$/,
|
|
|
|
use: 'vue-html-loader'
|
|
|
|
},
|
2019-03-20 16:07:21 +01:00
|
|
|
{
|
|
|
|
test: /\.ts$/,
|
|
|
|
exclude: /node_modules/,
|
2019-04-18 09:15:50 +02:00
|
|
|
use: [
|
|
|
|
{
|
2022-05-01 11:02:47 +02:00
|
|
|
loader: 'babel-loader?cacheDirectory'
|
2019-04-18 09:15:50 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
loader: 'ts-loader',
|
|
|
|
options: {
|
2022-05-01 11:02:47 +02:00
|
|
|
appendTsSuffixTo: [/\.vue$/],
|
|
|
|
transpileOnly: true
|
2019-04-18 09:15:50 +02:00
|
|
|
}
|
2019-03-20 17:03:53 +01:00
|
|
|
}
|
2019-04-18 09:15:50 +02:00
|
|
|
]
|
2019-03-20 16:07:21 +01:00
|
|
|
},
|
2018-03-07 14:28:48 +01:00
|
|
|
{
|
|
|
|
test: /\.js$/,
|
2022-05-01 11:02:47 +02:00
|
|
|
use: 'babel-loader?cacheDirectory',
|
2018-03-07 14:28:48 +01:00
|
|
|
exclude: /node_modules/
|
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.node$/,
|
|
|
|
use: 'node-loader'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
|
|
|
|
use: {
|
|
|
|
loader: 'url-loader',
|
2020-01-13 17:24:59 +01:00
|
|
|
options: {
|
2018-03-07 14:28:48 +01:00
|
|
|
limit: 10000,
|
2020-01-13 17:24:59 +01:00
|
|
|
name: 'imgs/[name]--[folder].[ext]',
|
|
|
|
esModule: false
|
2018-03-07 14:28:48 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.(mp4|webm|ogg|mp3|wav|flac|aac)(\?.*)?$/,
|
|
|
|
loader: 'url-loader',
|
|
|
|
options: {
|
|
|
|
limit: 10000,
|
|
|
|
name: 'media/[name]--[folder].[ext]'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
|
|
|
|
use: {
|
|
|
|
loader: 'url-loader',
|
2021-05-22 13:56:48 +02:00
|
|
|
options: {
|
2018-03-07 14:28:48 +01:00
|
|
|
limit: 10000,
|
|
|
|
name: 'fonts/[name]--[folder].[ext]'
|
|
|
|
}
|
|
|
|
}
|
2019-11-26 16:29:02 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.json$/,
|
|
|
|
exclude: /node_modules/,
|
|
|
|
use: 'json-loader',
|
|
|
|
type: 'javascript/auto'
|
2018-03-07 14:28:48 +01:00
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
node: {
|
|
|
|
__dirname: process.env.NODE_ENV !== 'production',
|
|
|
|
__filename: process.env.NODE_ENV !== 'production'
|
|
|
|
},
|
2021-12-29 10:43:48 +01:00
|
|
|
devServer: {
|
2023-01-13 18:00:51 +01:00
|
|
|
hot: true,
|
2021-12-29 10:43:48 +01:00
|
|
|
hotOnly: true
|
|
|
|
},
|
2018-03-07 14:28:48 +01:00
|
|
|
plugins: [
|
2018-11-12 15:54:39 +01:00
|
|
|
new VueLoaderPlugin(),
|
2019-11-26 15:03:24 +01:00
|
|
|
new MiniCssExtractPlugin({ filename: 'styles.css' }),
|
2018-03-07 14:28:48 +01:00
|
|
|
new HtmlWebpackPlugin({
|
|
|
|
filename: 'index.html',
|
|
|
|
template: path.resolve(__dirname, '../src/index.ejs'),
|
|
|
|
minify: {
|
|
|
|
collapseWhitespace: true,
|
|
|
|
removeAttributeQuotes: true,
|
|
|
|
removeComments: true
|
|
|
|
},
|
2019-11-26 15:03:24 +01:00
|
|
|
nodeModules: process.env.NODE_ENV !== 'production' ? path.resolve(__dirname, '../node_modules') : false
|
2018-03-07 14:28:48 +01:00
|
|
|
}),
|
2022-04-09 18:10:14 +02:00
|
|
|
new webpack.NoEmitOnErrorsPlugin(),
|
|
|
|
new webpack.DefinePlugin({
|
|
|
|
'process.browser': true,
|
|
|
|
'process.env.NODE_DEBUG': false
|
|
|
|
}),
|
|
|
|
new webpack.ProvidePlugin({
|
|
|
|
Buffer: ['buffer', 'Buffer']
|
|
|
|
}),
|
|
|
|
new webpack.ProvidePlugin({
|
|
|
|
process: 'process/browser'
|
|
|
|
})
|
2018-03-07 14:28:48 +01:00
|
|
|
],
|
|
|
|
output: {
|
|
|
|
filename: '[name].js',
|
|
|
|
path: path.join(__dirname, '../dist/electron')
|
|
|
|
},
|
|
|
|
resolve: {
|
|
|
|
alias: {
|
2019-03-21 15:23:57 +01:00
|
|
|
// Same as tsconfig.json
|
2018-03-07 14:28:48 +01:00
|
|
|
'@': path.join(__dirname, '../src/renderer'),
|
2022-04-18 15:39:46 +02:00
|
|
|
'~': path.join(__dirname, '../')
|
2018-03-07 14:28:48 +01:00
|
|
|
},
|
2022-04-09 18:10:14 +02:00
|
|
|
extensions: ['.ts', '.js', '.vue', '.json', '.css', '.node'],
|
|
|
|
fallback: {
|
|
|
|
timers: require.resolve('timers-browserify'),
|
|
|
|
url: require.resolve('url/'),
|
|
|
|
assert: require.resolve('assert/'),
|
|
|
|
buffer: require.resolve('buffer/'),
|
|
|
|
os: require.resolve('os-browserify/browser'),
|
|
|
|
path: require.resolve('path-browserify'),
|
|
|
|
crypto: require.resolve('crypto-browserify'),
|
|
|
|
http: require.resolve('stream-http'),
|
|
|
|
https: require.resolve('https-browserify'),
|
|
|
|
stream: require.resolve('stream-browserify'),
|
|
|
|
zlib: require.resolve('browserify-zlib'),
|
|
|
|
net: false,
|
|
|
|
tls: false,
|
|
|
|
fs: false,
|
|
|
|
dns: false
|
|
|
|
}
|
2018-03-07 14:28:48 +01:00
|
|
|
},
|
2022-04-09 18:10:14 +02:00
|
|
|
target: 'web'
|
2018-03-07 14:28:48 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Adjust rendererConfig for development settings
|
|
|
|
*/
|
|
|
|
if (process.env.NODE_ENV !== 'production') {
|
|
|
|
rendererConfig.plugins.push(
|
|
|
|
new webpack.DefinePlugin({
|
2019-11-26 15:03:24 +01:00
|
|
|
__static: `"${path.join(__dirname, '../static').replace(/\\/g, '\\\\')}"`
|
2018-03-07 14:28:48 +01:00
|
|
|
})
|
|
|
|
)
|
2021-05-22 14:50:45 +02:00
|
|
|
rendererConfig.devtool = 'eval-cheap-module-source-map'
|
2018-03-07 14:28:48 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Adjust rendererConfig for production settings
|
|
|
|
*/
|
|
|
|
if (process.env.NODE_ENV === 'production') {
|
2019-12-21 15:20:50 +01:00
|
|
|
rendererConfig.mode = 'production'
|
2018-03-07 14:28:48 +01:00
|
|
|
rendererConfig.plugins.push(
|
2020-05-27 17:45:42 +02:00
|
|
|
new CopyWebpackPlugin({
|
|
|
|
patterns: [
|
|
|
|
{
|
|
|
|
from: path.join(__dirname, '../static'),
|
|
|
|
to: path.join(__dirname, '../dist/electron/static'),
|
|
|
|
globOptions: {
|
|
|
|
ignore: ['.*', '*~']
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}),
|
2018-03-07 14:28:48 +01:00
|
|
|
new webpack.DefinePlugin({
|
|
|
|
'process.env.NODE_ENV': '"production"'
|
|
|
|
}),
|
|
|
|
new webpack.LoaderOptionsPlugin({
|
|
|
|
minimize: true
|
|
|
|
})
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = rendererConfig
|