Toolkit: use src/README.md if it exists (#23271)

This commit is contained in:
Ryan McKinley
2020-04-01 22:06:01 -07:00
committed by GitHub
parent a6f2ae1fbd
commit 7bb6ff30c3
@@ -82,6 +82,7 @@ const getEntries = async () => {
}; };
const getCommonPlugins = (options: WebpackConfigurationOptions) => { const getCommonPlugins = (options: WebpackConfigurationOptions) => {
const hasREADME = fs.existsSync(path.resolve(process.cwd(), 'src', 'README.md'));
const packageJson = require(path.resolve(process.cwd(), 'package.json')); const packageJson = require(path.resolve(process.cwd(), 'package.json'));
return [ return [
new MiniCssExtractPlugin({ new MiniCssExtractPlugin({
@@ -91,8 +92,9 @@ const getCommonPlugins = (options: WebpackConfigurationOptions) => {
new webpack.optimize.OccurrenceOrderPlugin(true), new webpack.optimize.OccurrenceOrderPlugin(true),
new CopyWebpackPlugin( new CopyWebpackPlugin(
[ [
// If src/README.md exists use it; otherwise the root README
{ from: hasREADME ? 'README.md' : '../README.md', to: '.', force: true },
{ from: 'plugin.json', to: '.' }, { from: 'plugin.json', to: '.' },
{ from: '../README.md', to: '.' },
{ from: '../LICENSE', to: '.' }, { from: '../LICENSE', to: '.' },
{ from: '**/*.json', to: '.' }, { from: '**/*.json', to: '.' },
{ from: '**/*.svg', to: '.' }, { from: '**/*.svg', to: '.' },