mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-12 16:47:26 +02:00
feat(v2): minor webpack build perf optimization (#1612)
* feat(v2): improve webpack build time * revert devtool * nits * nits * prettier
This commit is contained in:
parent
95fde5f827
commit
d57110d15c
6 changed files with 24 additions and 7 deletions
|
@ -359,7 +359,7 @@ module.exports = function(context, opts) {
|
||||||
{
|
{
|
||||||
loader: path.resolve(__dirname, './markdownLoader.js'),
|
loader: path.resolve(__dirname, './markdownLoader.js'),
|
||||||
},
|
},
|
||||||
],
|
].filter(Boolean),
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
|
|
@ -181,7 +181,7 @@ module.exports = function(context, opts) {
|
||||||
sourceToPermalink: globalContents.sourceToPermalink,
|
sourceToPermalink: globalContents.sourceToPermalink,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
],
|
].filter(Boolean),
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
|
|
@ -68,6 +68,7 @@
|
||||||
"semver": "^6.1.1",
|
"semver": "^6.1.1",
|
||||||
"shelljs": "^0.8.3",
|
"shelljs": "^0.8.3",
|
||||||
"static-site-generator-webpack-plugin": "^3.4.2",
|
"static-site-generator-webpack-plugin": "^3.4.2",
|
||||||
|
"std-env": "^2.2.1",
|
||||||
"style-loader": "^0.23.1",
|
"style-loader": "^0.23.1",
|
||||||
"terser-webpack-plugin": "^1.3.0",
|
"terser-webpack-plugin": "^1.3.0",
|
||||||
"wait-file": "^1.0.1",
|
"wait-file": "^1.0.1",
|
||||||
|
|
|
@ -10,7 +10,7 @@ import MiniCssExtractPlugin from 'mini-css-extract-plugin';
|
||||||
import OptimizeCSSAssetsPlugin from 'optimize-css-assets-webpack-plugin';
|
import OptimizeCSSAssetsPlugin from 'optimize-css-assets-webpack-plugin';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import TerserPlugin from 'terser-webpack-plugin';
|
import TerserPlugin from 'terser-webpack-plugin';
|
||||||
import {Configuration} from 'webpack';
|
import {Configuration, Loader} from 'webpack';
|
||||||
|
|
||||||
import {Props} from '../server/types';
|
import {Props} from '../server/types';
|
||||||
import {getBabelLoader, getCacheLoader, getStyleLoaders} from './utils';
|
import {getBabelLoader, getCacheLoader, getStyleLoaders} from './utils';
|
||||||
|
@ -34,6 +34,7 @@ export function createBaseConfig(
|
||||||
return {
|
return {
|
||||||
mode: isProd ? 'production' : 'development',
|
mode: isProd ? 'production' : 'development',
|
||||||
output: {
|
output: {
|
||||||
|
pathinfo: false,
|
||||||
path: outDir,
|
path: outDir,
|
||||||
filename: isProd ? '[name].[chunkhash].js' : '[name].js',
|
filename: isProd ? '[name].[chunkhash].js' : '[name].js',
|
||||||
chunkFilename: isProd ? '[name].[chunkhash].js' : '[name].js',
|
chunkFilename: isProd ? '[name].[chunkhash].js' : '[name].js',
|
||||||
|
@ -43,7 +44,7 @@ export function createBaseConfig(
|
||||||
performance: {
|
performance: {
|
||||||
hints: false,
|
hints: false,
|
||||||
},
|
},
|
||||||
devtool: !isProd && 'cheap-module-eval-source-map',
|
devtool: isProd ? false : 'cheap-module-eval-source-map',
|
||||||
resolve: {
|
resolve: {
|
||||||
symlinks: true,
|
symlinks: true,
|
||||||
alias: {
|
alias: {
|
||||||
|
@ -132,7 +133,7 @@ export function createBaseConfig(
|
||||||
use: [
|
use: [
|
||||||
cacheLoader && getCacheLoader(isServer),
|
cacheLoader && getCacheLoader(isServer),
|
||||||
getBabelLoader(isServer),
|
getBabelLoader(isServer),
|
||||||
].filter(Boolean),
|
].filter(Boolean) as Loader[],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
test: CSS_REGEX,
|
test: CSS_REGEX,
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import MiniCssExtractPlugin from 'mini-css-extract-plugin';
|
import MiniCssExtractPlugin from 'mini-css-extract-plugin';
|
||||||
|
import env from 'std-env';
|
||||||
import merge from 'webpack-merge';
|
import merge from 'webpack-merge';
|
||||||
import {Configuration, Loader} from 'webpack';
|
import {Configuration, Loader} from 'webpack';
|
||||||
|
|
||||||
|
@ -43,7 +44,14 @@ export function getStyleLoaders(
|
||||||
return loaders;
|
return loaders;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getCacheLoader(isServer: boolean, cacheOptions?: {}): Loader {
|
export function getCacheLoader(
|
||||||
|
isServer: boolean,
|
||||||
|
cacheOptions?: {},
|
||||||
|
): Loader | null {
|
||||||
|
if (env.ci || env.test) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
loader: require.resolve('cache-loader'),
|
loader: require.resolve('cache-loader'),
|
||||||
options: Object.assign(
|
options: Object.assign(
|
||||||
|
|
|
@ -3712,7 +3712,7 @@ chrome-trace-event@^1.0.0:
|
||||||
dependencies:
|
dependencies:
|
||||||
tslib "^1.9.0"
|
tslib "^1.9.0"
|
||||||
|
|
||||||
ci-info@^1.5.0:
|
ci-info@^1.5.0, ci-info@^1.6.0:
|
||||||
version "1.6.0"
|
version "1.6.0"
|
||||||
resolved "https://registry.yarnpkg.com/ci-info/-/ci-info-1.6.0.tgz#2ca20dbb9ceb32d4524a683303313f0304b1e497"
|
resolved "https://registry.yarnpkg.com/ci-info/-/ci-info-1.6.0.tgz#2ca20dbb9ceb32d4524a683303313f0304b1e497"
|
||||||
integrity sha512-vsGdkwSCDpWmP80ncATX7iea5DWQemg1UgCW5J8tqjU3lYw4FBYuj89J0CTVomA7BEfvSZd84GmHko+MxFQU2A==
|
integrity sha512-vsGdkwSCDpWmP80ncATX7iea5DWQemg1UgCW5J8tqjU3lYw4FBYuj89J0CTVomA7BEfvSZd84GmHko+MxFQU2A==
|
||||||
|
@ -13097,6 +13097,13 @@ std-env@^1.1.0, std-env@^1.3.1:
|
||||||
dependencies:
|
dependencies:
|
||||||
is-ci "^1.1.0"
|
is-ci "^1.1.0"
|
||||||
|
|
||||||
|
std-env@^2.2.1:
|
||||||
|
version "2.2.1"
|
||||||
|
resolved "https://registry.yarnpkg.com/std-env/-/std-env-2.2.1.tgz#2ffa0fdc9e2263e0004c1211966e960948a40f6b"
|
||||||
|
integrity sha512-IjYQUinA3lg5re/YMlwlfhqNRTzMZMqE+pezevdcTaHceqx8ngEi1alX9nNCk9Sc81fy1fLDeQoaCzeiW1yBOQ==
|
||||||
|
dependencies:
|
||||||
|
ci-info "^1.6.0"
|
||||||
|
|
||||||
stealthy-require@^1.1.1:
|
stealthy-require@^1.1.1:
|
||||||
version "1.1.1"
|
version "1.1.1"
|
||||||
resolved "https://registry.yarnpkg.com/stealthy-require/-/stealthy-require-1.1.1.tgz#35b09875b4ff49f26a777e509b3090a3226bf24b"
|
resolved "https://registry.yarnpkg.com/stealthy-require/-/stealthy-require-1.1.1.tgz#35b09875b4ff49f26a777e509b3090a3226bf24b"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue