mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-13 09:07:29 +02:00
v2: prepare to move
This commit is contained in:
parent
dc7ef96849
commit
45736200b0
172 changed files with 0 additions and 0 deletions
43
v2/lib/webpack/server.js
Normal file
43
v2/lib/webpack/server.js
Normal file
|
@ -0,0 +1,43 @@
|
|||
const path = require('path');
|
||||
const staticSiteGenerator = require('static-site-generator-webpack-plugin');
|
||||
const webpackNiceLog = require('webpack-nicelog');
|
||||
const createBaseConfig = require('./base');
|
||||
const {applyChainWebpack} = require('./utils');
|
||||
|
||||
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)
|
||||
config.output.globalObject('this');
|
||||
|
||||
const {siteConfig, docsMetadatas, pagesMetadatas} = props;
|
||||
|
||||
// static site generator webpack plugin
|
||||
const docsLinks = Object.values(docsMetadatas).map(data => ({
|
||||
path: `${data.permalink}`
|
||||
}));
|
||||
const paths = [...docsLinks, ...pagesMetadatas].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'}]);
|
||||
|
||||
// user extended webpack-chain config
|
||||
applyChainWebpack(props.siteConfig.chainWebpack, config, true);
|
||||
|
||||
return config;
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue