Skip to content

Commit

Permalink
feat: add --no-minify flag to docusaurus start (#7452)
Browse files Browse the repository at this point in the history
* feat: Adding --no-minify flag to start

* Undoing the changes to old docs

Co-authored-by: Lane Goolsby <[email protected]>
  • Loading branch information
lanegoolsby and Lane Goolsby authored May 20, 2022
1 parent ba0d94d commit 5aaa33f
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 25 deletions.
4 changes: 4 additions & 0 deletions packages/docusaurus/bin/docusaurus.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
);
Expand Down
54 changes: 29 additions & 25 deletions packages/docusaurus/src/commands/start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export type StartCLIOptions = HostPortOptions &
hotOnly?: boolean;
open?: boolean;
poll?: boolean | number;
minify?: boolean;
};

export async function start(
Expand Down Expand Up @@ -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,
},
infrastructureLogging: {
// Reduce log verbosity, see https://github.com/facebook/docusaurus/pull/5420#issuecomment-906613105
level: 'warn',
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,
}),
],
},
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) => {
Expand Down
1 change: 1 addition & 0 deletions website/docs/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 5aaa33f

Please sign in to comment.