mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-17 11:07:07 +02:00
feat(v2): don't output server.bundle.js to disk (#1361)
This commit is contained in:
parent
fbfb26e17c
commit
ecb4f91669
2 changed files with 10 additions and 3 deletions
|
@ -7,6 +7,7 @@
|
|||
|
||||
const webpack = require('webpack');
|
||||
const merge = require('webpack-merge');
|
||||
const MemoryFS = require('memory-fs');
|
||||
const CleanWebpackPlugin = require('clean-webpack-plugin');
|
||||
const {BundleAnalyzerPlugin} = require('webpack-bundle-analyzer');
|
||||
const path = require('path');
|
||||
|
@ -18,9 +19,14 @@ const createServerConfig = require('../webpack/server');
|
|||
const createClientConfig = require('../webpack/client');
|
||||
const {applyConfigureWebpack} = require('../webpack/utils');
|
||||
|
||||
function compile(config) {
|
||||
function compile(config, isServer) {
|
||||
return new Promise((resolve, reject) => {
|
||||
webpack(config, (err, stats) => {
|
||||
const compiler = webpack(config);
|
||||
if (isServer) {
|
||||
// Don't output server bundle to disk. Write files to memory instead
|
||||
compiler.outputFileSystem = new MemoryFS();
|
||||
}
|
||||
compiler.run((err, stats) => {
|
||||
if (err) {
|
||||
reject(err);
|
||||
}
|
||||
|
@ -84,7 +90,7 @@ module.exports = async function build(siteDir, cliOptions = {}) {
|
|||
await compile(clientConfig);
|
||||
|
||||
// Build the server bundles (render the static HTML and pick client bundle),
|
||||
await compile(serverConfig);
|
||||
await compile(serverConfig, true);
|
||||
|
||||
// Copy static files.
|
||||
const staticDir = path.resolve(siteDir, 'static');
|
||||
|
|
|
@ -55,6 +55,7 @@
|
|||
"html-webpack-plugin": "^3.2.0",
|
||||
"is-wsl": "^1.1.0",
|
||||
"lodash": "^4.17.11",
|
||||
"memory-fs": "^0.4.1",
|
||||
"mini-css-extract-plugin": "^0.4.1",
|
||||
"portfinder": "^1.0.13",
|
||||
"react-dev-utils": "^8.0.0",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue