mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-14 09:37:37 +02:00
chore: nits
This commit is contained in:
parent
e13e1bffb4
commit
1f2c8a39a9
4 changed files with 7 additions and 8 deletions
|
@ -58,6 +58,7 @@ module.exports = async function start(siteDir, cliOptions = {}) {
|
||||||
const {siteConfig} = props;
|
const {siteConfig} = props;
|
||||||
config.plugin('html-webpack-plugin').use(HtmlWebpackPlugin, [
|
config.plugin('html-webpack-plugin').use(HtmlWebpackPlugin, [
|
||||||
{
|
{
|
||||||
|
inject: false,
|
||||||
hash: true,
|
hash: true,
|
||||||
template: path.resolve(__dirname, '../core/devTemplate.ejs'),
|
template: path.resolve(__dirname, '../core/devTemplate.ejs'),
|
||||||
filename: 'index.html',
|
filename: 'index.html',
|
||||||
|
|
|
@ -35,8 +35,8 @@ async function genRoutesConfig({docsData = [], pagesData = []}) {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
`import React from 'react';\n` +
|
`import React from 'react';\n` +
|
||||||
`import Loading from '@theme/Loading';\n` +
|
|
||||||
`import Loadable from 'react-loadable';\n` +
|
`import Loadable from 'react-loadable';\n` +
|
||||||
|
`import Loading from '@theme/Loading';\n` +
|
||||||
`import Docs from '@theme/Docs';\n` +
|
`import Docs from '@theme/Docs';\n` +
|
||||||
`import NotFound from '@theme/NotFound';\n` +
|
`import NotFound from '@theme/NotFound';\n` +
|
||||||
`const routes = [${docsData.map(genDocsRoute).join(',')},${pagesData
|
`const routes = [${docsData.map(genDocsRoute).join(',')},${pagesData
|
||||||
|
|
|
@ -6,21 +6,20 @@ const createBaseConfig = require('./base');
|
||||||
|
|
||||||
module.exports = function createClientConfig(props) {
|
module.exports = function createClientConfig(props) {
|
||||||
const config = createBaseConfig(props);
|
const config = createBaseConfig(props);
|
||||||
|
|
||||||
config.entry('main').add(path.resolve(__dirname, '../core/clientEntry.js'));
|
config.entry('main').add(path.resolve(__dirname, '../core/clientEntry.js'));
|
||||||
|
|
||||||
|
// remove/clean build folders before building bundles
|
||||||
const {outDir} = props;
|
const {outDir} = props;
|
||||||
config
|
config
|
||||||
.plugin('clean')
|
.plugin('clean')
|
||||||
.use(cleanWebpackPlugin, [outDir, {verbose: false, allowExternal: true}]);
|
.use(cleanWebpackPlugin, [outDir, {verbose: false, allowExternal: true}]);
|
||||||
|
|
||||||
// write webpack stats object to a file so we can
|
// write webpack stats object so we can pickup correct client bundle path in server.
|
||||||
// programmatically refer to the correct bundle path in Node.js server.
|
|
||||||
config
|
config
|
||||||
.plugin('stats')
|
.plugin('stats')
|
||||||
.use(StatsWriterPlugin, [{filename: 'client.stats.json'}]);
|
.use(StatsWriterPlugin, [{filename: 'client.stats.json'}]);
|
||||||
|
|
||||||
|
// show compilation progress bar and build time
|
||||||
config.plugin('niceLog').use(webpackNiceLog, [{name: 'Client'}]);
|
config.plugin('niceLog').use(webpackNiceLog, [{name: 'Client'}]);
|
||||||
|
|
||||||
return config;
|
return config;
|
||||||
};
|
};
|
||||||
|
|
|
@ -3,13 +3,11 @@ const staticSiteGenerator = require('static-site-generator-webpack-plugin');
|
||||||
const webpackNiceLog = require('webpack-nicelog');
|
const webpackNiceLog = require('webpack-nicelog');
|
||||||
const createBaseConfig = require('./base');
|
const createBaseConfig = require('./base');
|
||||||
|
|
||||||
module.exports = function createProdConfig(props) {
|
module.exports = function createServerConfig(props) {
|
||||||
const config = createBaseConfig(props, true);
|
const config = createBaseConfig(props, true);
|
||||||
|
|
||||||
config.entry('main').add(path.resolve(__dirname, '../core/serverEntry.js'));
|
config.entry('main').add(path.resolve(__dirname, '../core/serverEntry.js'));
|
||||||
|
|
||||||
config.target('node');
|
config.target('node');
|
||||||
|
|
||||||
config.output.filename('server.bundle.js').libraryTarget('commonjs2');
|
config.output.filename('server.bundle.js').libraryTarget('commonjs2');
|
||||||
|
|
||||||
// Workaround for Webpack 4 Bug (https://github.com/webpack/webpack/issues/6522)
|
// Workaround for Webpack 4 Bug (https://github.com/webpack/webpack/issues/6522)
|
||||||
|
@ -28,6 +26,7 @@ module.exports = function createProdConfig(props) {
|
||||||
paths
|
paths
|
||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// show compilation progress bar and build time
|
// show compilation progress bar and build time
|
||||||
config
|
config
|
||||||
.plugin('niceLog')
|
.plugin('niceLog')
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue