From e60fb15311d643db6e8ddcc4122f96d658b5eea0 Mon Sep 17 00:00:00 2001 From: Simon Leigh Date: Thu, 19 Dec 2019 17:44:48 +0900 Subject: [PATCH 1/2] added publicPath for non-electron build --- now.json | 2 +- webpack.config.ts | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/now.json b/now.json index 3fd118f823..1ef05ee8d3 100644 --- a/now.json +++ b/now.json @@ -18,7 +18,7 @@ ], "routes": [ { - "src": "/app/(.*.?bundle.js)", + "src": "/app/(.*\\.?bundle.js)$", "dest": "/compiled/$1" }, { diff --git a/webpack.config.ts b/webpack.config.ts index 94ae29c63e..e21e7c14d2 100644 --- a/webpack.config.ts +++ b/webpack.config.ts @@ -16,7 +16,6 @@ module.exports = (env, argv) => { output: { filename: 'bundle.js', // the output bundle - path: path.resolve(__dirname, 'compiled') }, @@ -95,7 +94,7 @@ module.exports = (env, argv) => { hot: true, // enable HMR on the server - before: function(app, server) { + before: function (app, server) { app.use( '/app/codemirror/mode', express.static(path.join(__dirname, 'node_modules/codemirror/mode')) @@ -128,11 +127,10 @@ module.exports = (env, argv) => { 'webpack-dev-server/client?http://localhost:3000', 'webpack/hot/only-dev-server' ) - ;(config.output as any).publicPath = '/app' } if (argv.mode === 'production') { - ;(config as any).optimization = { + ; (config as any).optimization = { minimize: true, minimizer: [ new TerserPlugin({ @@ -144,5 +142,9 @@ module.exports = (env, argv) => { } } + if (process.env.TARGET !== 'electron') { + (config.output as any).publicPath = '/app/' + } + return config } From e3f153887ffc5086b56e626dbea19c2eacca6740 Mon Sep 17 00:00:00 2001 From: Simon Leigh Date: Thu, 19 Dec 2019 17:51:40 +0900 Subject: [PATCH 2/2] formatting --- webpack.config.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/webpack.config.ts b/webpack.config.ts index e21e7c14d2..658ee86f1c 100644 --- a/webpack.config.ts +++ b/webpack.config.ts @@ -94,7 +94,7 @@ module.exports = (env, argv) => { hot: true, // enable HMR on the server - before: function (app, server) { + before: function(app, server) { app.use( '/app/codemirror/mode', express.static(path.join(__dirname, 'node_modules/codemirror/mode')) @@ -130,7 +130,7 @@ module.exports = (env, argv) => { } if (argv.mode === 'production') { - ; (config as any).optimization = { + ;(config as any).optimization = { minimize: true, minimizer: [ new TerserPlugin({ @@ -143,7 +143,7 @@ module.exports = (env, argv) => { } if (process.env.TARGET !== 'electron') { - (config.output as any).publicPath = '/app/' + ;(config.output as any).publicPath = '/app/' } return config