npx create-react-app sampleapp
cd sampleapp
Now install the gulp
library inside the react.js
app by the following command as shown below
1 |
npm install --save-dev gulp gulp-inline-source gulp-replace |
Now create a .env
file inside the root folder and copy paste the below code
.env
1 2 3 |
INLINE_RUNTIME_CHUNK=false GENERATE_SOURCEMAP=false SKIP_PREFLIGHT_CHECK=true |
Now create a gulpfile.js
inside the root directory and copy paste the following code
gulpfile.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
const gulp = require('gulp'); const inlinesource = require('gulp-inline-source'); const replace = require('gulp-replace'); gulp.task('default', () => { return gulp .src('./build/*.html') .pipe(replace('.js"></script>', '.js" inline></script>')) .pipe(replace('rel="stylesheet">', 'rel="stylesheet" inline>')) .pipe( inlinesource({ compress: false, ignore: ['png'], }) ) .pipe(gulp.dest('./build')); }); |
And now run the below commands to build
the app
npm run build
npx gulp
Now you will get the minified
index.html which you can upload to your server
or localhost
to run the app