October 2017
Intermediate to advanced
302 pages
7h 27m
English
Make a new folder in the root of your directory and name it scripts. Inside, make a file called copy_assets.js.
In here, we will copy everything in public to build, excluding our index.html.
To do this (you guessed it), we need one more package; run yarn add fs-extra.
Then, require it inside copy_assets.js, as illustrated:
var fs = require('fs-extra');
fs-extra is a package used for manipulating files in a Node environment. It has a method called copySync, which we'll use here.
The code is rather straightforward:
fs.copySync('public', 'build', { dereference: true, filter: file => file !== 'public/index.html'});
This says copy everything in the public folder to the build folder, except the index.html file.
Read now
Unlock full access