diff --git a/lib/commands/start.js b/lib/commands/start.js index a8ee2f4f5f..9550eab7c1 100644 --- a/lib/commands/start.js +++ b/lib/commands/start.js @@ -58,6 +58,7 @@ module.exports = async function start(siteDir, cliOptions = {}) { const {siteConfig} = props; config.plugin('html-webpack-plugin').use(HtmlWebpackPlugin, [ { + inject: false, hash: true, template: path.resolve(__dirname, '../core/devTemplate.ejs'), filename: 'index.html', diff --git a/lib/load/routes.js b/lib/load/routes.js index 286ca42b76..282446327a 100644 --- a/lib/load/routes.js +++ b/lib/load/routes.js @@ -35,8 +35,8 @@ async function genRoutesConfig({docsData = [], pagesData = []}) { return ( `import React from 'react';\n` + - `import Loading from '@theme/Loading';\n` + `import Loadable from 'react-loadable';\n` + + `import Loading from '@theme/Loading';\n` + `import Docs from '@theme/Docs';\n` + `import NotFound from '@theme/NotFound';\n` + `const routes = [${docsData.map(genDocsRoute).join(',')},${pagesData diff --git a/lib/webpack/client.js b/lib/webpack/client.js index af01ba309c..8c438ebc71 100644 --- a/lib/webpack/client.js +++ b/lib/webpack/client.js @@ -6,21 +6,20 @@ const createBaseConfig = require('./base'); module.exports = function createClientConfig(props) { const config = createBaseConfig(props); - config.entry('main').add(path.resolve(__dirname, '../core/clientEntry.js')); + // remove/clean build folders before building bundles const {outDir} = props; config .plugin('clean') .use(cleanWebpackPlugin, [outDir, {verbose: false, allowExternal: true}]); - // write webpack stats object to a file so we can - // programmatically refer to the correct bundle path in Node.js server. + // write webpack stats object so we can pickup correct client bundle path in server. config .plugin('stats') .use(StatsWriterPlugin, [{filename: 'client.stats.json'}]); + // show compilation progress bar and build time config.plugin('niceLog').use(webpackNiceLog, [{name: 'Client'}]); - return config; }; diff --git a/lib/webpack/server.js b/lib/webpack/server.js index a562199727..33b6fe0c29 100644 --- a/lib/webpack/server.js +++ b/lib/webpack/server.js @@ -3,13 +3,11 @@ const staticSiteGenerator = require('static-site-generator-webpack-plugin'); const webpackNiceLog = require('webpack-nicelog'); const createBaseConfig = require('./base'); -module.exports = function createProdConfig(props) { +module.exports = function createServerConfig(props) { const config = createBaseConfig(props, true); config.entry('main').add(path.resolve(__dirname, '../core/serverEntry.js')); - config.target('node'); - config.output.filename('server.bundle.js').libraryTarget('commonjs2'); // Workaround for Webpack 4 Bug (https://github.com/webpack/webpack/issues/6522) @@ -28,6 +26,7 @@ module.exports = function createProdConfig(props) { paths } ]); + // show compilation progress bar and build time config .plugin('niceLog')