feat: add --no-minify flag to docusaurus start (#7452)

* feat: Adding --no-minify flag to start

* Undoing the changes to old docs

Co-authored-by: Lane Goolsby <lanegoolsby@rocketmortgage.com>
This commit is contained in:
Lane Goolsby 2022-05-19 21:50:17 -07:00 committed by GitHub
parent ba0d94d02b
commit 5aaa33fc61
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 34 additions and 25 deletions

View file

@ -126,6 +126,10 @@ cli
'--poll [interval]',
'use polling rather than watching for reload (default: false). Can specify a poll interval in milliseconds',
)
.option(
'--no-minify',
'build website without minimizing JS bundles (default: false)',
)
.action(async (siteDir, options) =>
start(await resolveDir(siteDir), options),
);

View file

@ -32,6 +32,7 @@ export type StartCLIOptions = HostPortOptions &
hotOnly?: boolean;
open?: boolean;
poll?: boolean | number;
minify?: boolean;
};
export async function start(
@ -121,32 +122,35 @@ export async function start(
fsWatcher.on(event, reload),
);
let config: webpack.Configuration = merge(await createClientConfig(props), {
watchOptions: {
ignored: /node_modules\/(?!@docusaurus)/,
poll: cliOptions.poll,
let config: webpack.Configuration = merge(
await createClientConfig(props, cliOptions.minify),
{
watchOptions: {
ignored: /node_modules\/(?!@docusaurus)/,
poll: cliOptions.poll,
},
infrastructureLogging: {
// Reduce log verbosity, see https://github.com/facebook/docusaurus/pull/5420#issuecomment-906613105
level: 'warn',
},
plugins: [
// Generates an `index.html` file with the <script> injected.
new HtmlWebpackPlugin({
template: path.join(
__dirname,
'../webpack/templates/index.html.template.ejs',
),
// So we can define the position where the scripts are injected.
inject: false,
filename: 'index.html',
title: siteConfig.title,
headTags,
preBodyTags,
postBodyTags,
}),
],
},
infrastructureLogging: {
// Reduce log verbosity, see https://github.com/facebook/docusaurus/pull/5420#issuecomment-906613105
level: 'warn',
},
plugins: [
// Generates an `index.html` file with the <script> injected.
new HtmlWebpackPlugin({
template: path.join(
__dirname,
'../webpack/templates/index.html.template.ejs',
),
// So we can define the position where the scripts are injected.
inject: false,
filename: 'index.html',
title: siteConfig.title,
headTags,
preBodyTags,
postBodyTags,
}),
],
});
);
// Plugin Lifecycle - configureWebpack and configurePostCss.
plugins.forEach((plugin) => {

View file

@ -43,6 +43,7 @@ Builds and serves a preview of your site locally with [Webpack Dev Server](https
| `--no-open` | `false` | Do not open automatically the page in the browser. |
| `--config` | `undefined` | Path to docusaurus config file, default to `[siteDir]/docusaurus.config.js` |
| `--poll [optionalIntervalMs]` | `false` | Use polling of files rather than watching for live reload as a fallback in environments where watching doesn't work. More information [here](https://webpack.js.org/configuration/watch/#watchoptionspoll). |
| `--no-minify` | `false` | Build website without minimizing JS/CSS bundles. |
:::important