Skip to content

Instantly share code, notes, and snippets.

@bryzettler
Last active June 10, 2020 08:18
Show Gist options
  • Save bryzettler/dde355176d1bd6f452d7c06a19668ba6 to your computer and use it in GitHub Desktop.
Save bryzettler/dde355176d1bd6f452d7c06a19668ba6 to your computer and use it in GitHub Desktop.
const build = () => {
const bundler = new Bundler(paths.appHtml, {
command: 'build',
outDir: paths.appBuild,
publicUrl: './',
cacheDir: './.parcelCache',
// Generate Source Maps for prod
sourceMaps: true,
});
Promise.resolve(bundler.bundle()).then(() => {
copyPublicFolder();
console.log('The ' + chalk.cyan('build') + ' folder is ready to be deployed.');
console.log('You may also serve it locally with a static server:')
console.log();
}).catch((err) => {
printErrors('Failed to compile.', [err]);
process.exit(1);
});
}
build();
@IoannisPetridis
Copy link

Hi I just stumbled upon your code from your medium article. Mind if I ask for details of the copyPublicFolder() func? Is it just copying files in the paths.appBuild folder?

@bryzettler
Copy link
Author

Hey @p10petr, Its been a while since that medium article but the copyPublicFolder was a fn in the build.js file of create-react-app. This is the current implementation that they have, found here src.

function copyPublicFolder() {
  fs.copySync(paths.appPublic, paths.appBuild, {
    dereference: true,
    filter: file => file !== paths.appHtml,
  });
}

@IoannisPetridis
Copy link

Cheers! Much appreciated :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment