mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-10 15:47:23 +02:00
feat: copy static files for production build
This commit is contained in:
parent
77ec02a278
commit
fa02f6ef60
2 changed files with 19 additions and 1 deletions
|
@ -4,3 +4,5 @@ title: Hello, World !
|
|||
---
|
||||
|
||||
Hi, Endilie here :)
|
||||
|
||||

|
|
@ -2,6 +2,8 @@ const webpackNiceLog = require('webpack-nicelog');
|
|||
const webpack = require('webpack');
|
||||
const path = require('path');
|
||||
const chalk = require('chalk');
|
||||
const fs = require('fs-extra');
|
||||
const globby = require('globby');
|
||||
const load = require('../load');
|
||||
const createProdConfig = require('../webpack/prod');
|
||||
|
||||
|
@ -51,6 +53,20 @@ module.exports = async function build(siteDir, cliOptions = {}) {
|
|||
await compile(config);
|
||||
|
||||
const {outDir} = props;
|
||||
|
||||
// copy static files
|
||||
const staticDir = path.resolve(siteDir, 'static');
|
||||
const staticFiles = await globby(['**'], {
|
||||
cwd: staticDir
|
||||
});
|
||||
await Promise.all(
|
||||
staticFiles.map(async source => {
|
||||
const fromPath = path.resolve(staticDir, source);
|
||||
const toPath = path.resolve(outDir, source);
|
||||
return fs.copy(fromPath, toPath);
|
||||
})
|
||||
);
|
||||
|
||||
const relativeDir = path.relative(process.cwd(), outDir);
|
||||
console.log(
|
||||
`\n${chalk.green('Success!')} Generated static files in ${chalk.cyan(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue