|
@@ -1,6 +1,21 @@
|
|
const HtmlWebpackInlineSourcePlugin = require('html-webpack-inline-source-plugin')
|
|
const HtmlWebpackInlineSourcePlugin = require('html-webpack-inline-source-plugin')
|
|
|
|
+const tauriConfig = require('../helpers/tauri-config')
|
|
|
|
+const WebpackShellPlugin = require('webpack-shell-plugin')
|
|
|
|
|
|
-module.exports.chain = function (chain, cfg) {
|
|
|
|
|
|
+const safeTap = (options, cb) => {
|
|
|
|
+ if (options !== undefined) {
|
|
|
|
+ cb()
|
|
|
|
+ }
|
|
|
|
+ return options
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+module.exports.chain = function (chain) {
|
|
|
|
+ const cfg = tauriConfig({
|
|
|
|
+ ctx: {
|
|
|
|
+ debug: process.env.NODE_ENV !== 'production',
|
|
|
|
+ prod: process.env.NODE_ENV === 'production'
|
|
|
|
+ }
|
|
|
|
+ })
|
|
if (!cfg.tauri.embeddedServer.active) {
|
|
if (!cfg.tauri.embeddedServer.active) {
|
|
chain.optimization.splitChunks({
|
|
chain.optimization.splitChunks({
|
|
chunks: 'all',
|
|
chunks: 'all',
|
|
@@ -41,14 +56,13 @@ module.exports.chain = function (chain, cfg) {
|
|
|
|
|
|
chain.module.rule('babel')
|
|
chain.module.rule('babel')
|
|
.use('babel-loader')
|
|
.use('babel-loader')
|
|
- .tap(options => {
|
|
|
|
|
|
+ .tap(options => safeTap(() => {
|
|
options.plugins.push([
|
|
options.plugins.push([
|
|
'system-import-transformer', { // needs constant attention
|
|
'system-import-transformer', { // needs constant attention
|
|
modules: 'common'
|
|
modules: 'common'
|
|
}
|
|
}
|
|
])
|
|
])
|
|
- return options
|
|
|
|
- })
|
|
|
|
|
|
+ }))
|
|
}
|
|
}
|
|
|
|
|
|
const modules = {
|
|
const modules = {
|
|
@@ -59,10 +73,9 @@ module.exports.chain = function (chain, cfg) {
|
|
for (const module in modules) {
|
|
for (const module in modules) {
|
|
chain.module.rule(module)
|
|
chain.module.rule(module)
|
|
.use(modules[module])
|
|
.use(modules[module])
|
|
- .tap(options => {
|
|
|
|
|
|
+ .tap(options => safeTap(options, () => {
|
|
options.limit = undefined
|
|
options.limit = undefined
|
|
- return options
|
|
|
|
- })
|
|
|
|
|
|
+ }))
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -70,4 +83,15 @@ module.exports.chain = function (chain, cfg) {
|
|
chain.plugin('html-webpack-inline-source')
|
|
chain.plugin('html-webpack-inline-source')
|
|
.use(HtmlWebpackInlineSourcePlugin)
|
|
.use(HtmlWebpackInlineSourcePlugin)
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ if (cfg.tauri.automaticStart.active) {
|
|
|
|
+ chain.plugin('webpack-shell-plugin')
|
|
|
|
+ .use(WebpackShellPlugin, [{
|
|
|
|
+ onBuildEnd: [
|
|
|
|
+ cfg.ctx.prod
|
|
|
|
+ ? `tauri build${cfg.tauri.automaticStart.buildArgs.join(' ')}`
|
|
|
|
+ : `tauri dev${cfg.tauri.automaticStart.devArgs.join(' ')}`
|
|
|
|
+ ]
|
|
|
|
+ }])
|
|
|
|
+ }
|
|
}
|
|
}
|