mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-13 00:57:53 +02:00
feat: code split & use react helmet
This commit is contained in:
parent
bf1e30dc52
commit
406106b67e
19 changed files with 241 additions and 146 deletions
37
lib/webpack/server.js
Normal file
37
lib/webpack/server.js
Normal file
|
@ -0,0 +1,37 @@
|
|||
const path = require('path');
|
||||
const staticSiteGenerator = require('static-site-generator-webpack-plugin');
|
||||
const webpackNiceLog = require('webpack-nicelog');
|
||||
const createBaseConfig = require('./base');
|
||||
|
||||
module.exports = function createProdConfig(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)
|
||||
config.output.globalObject('this');
|
||||
|
||||
const {siteConfig, docsData, pagesData} = props;
|
||||
|
||||
// static site generator webpack plugin
|
||||
const paths = [...docsData, ...pagesData].map(data => data.path);
|
||||
config.plugin('siteGenerator').use(staticSiteGenerator, [
|
||||
{
|
||||
entry: 'main',
|
||||
locals: {
|
||||
baseUrl: siteConfig.baseUrl
|
||||
},
|
||||
paths
|
||||
}
|
||||
]);
|
||||
// show compilation progress bar and build time
|
||||
config
|
||||
.plugin('niceLog')
|
||||
.use(webpackNiceLog, [{name: 'Server', color: 'yellow'}]);
|
||||
|
||||
return config;
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue