From f9d409326332f086eff282d7ad048d67e459cea2 Mon Sep 17 00:00:00 2001 From: Guillaume Chau Date: Sun, 20 Oct 2019 22:18:33 +0200 Subject: [PATCH] feat: use a different html file so spa `serve` still works --- .../default/public/{index.html => index.ssr.html} | 0 lib/default-config.js | 2 +- lib/webpack.js | 9 +++++++++ 3 files changed, 10 insertions(+), 1 deletion(-) rename generator/templates/default/public/{index.html => index.ssr.html} (100%) diff --git a/generator/templates/default/public/index.html b/generator/templates/default/public/index.ssr.html similarity index 100% rename from generator/templates/default/public/index.html rename to generator/templates/default/public/index.ssr.html diff --git a/lib/default-config.js b/lib/default-config.js index c3158b2..90e9935 100644 --- a/lib/default-config.js +++ b/lib/default-config.js @@ -3,7 +3,7 @@ module.exports = (api, options) => { return { distPath: api.resolve(outputPath), - templatePath: api.resolve(`${outputPath}/index.html`), + templatePath: api.resolve(`${outputPath}/index.ssr.html`), serviceWorkerPath: api.resolve(`${outputPath}/service-worker.js`), } } diff --git a/lib/webpack.js b/lib/webpack.js index bd268a5..2e4993d 100644 --- a/lib/webpack.js +++ b/lib/webpack.js @@ -50,6 +50,15 @@ exports.chainWebpack = (webpackConfig) => { }) } + const htmlPlugin = webpackConfig.plugins.get('html').store + webpackConfig.plugin('html-ssr').use(htmlPlugin.get('plugin'), [ + { + ...htmlPlugin.get('args')[0], + template: config.api.resolve('public/index.ssr.html'), + filename: 'index.ssr.html', + }, + ]) + webpackConfig.entry('app').clear().add(config.entry(target)) webpackConfig.plugin('define').tap(args => {