On Parcel build end, change index.html context, and copy static files in outDir
$ yarn add -D parcel-plugin-change-file
Add <!--[ your-code ]-->
<body>
<!--[ <script src="lodash.min.js"></script> ]-->
</bodt>
The lodash.min.js jump to parcel bundler, this build end html:
<body>
<script src="lodash.min.js"></script>
</bodt>
Add <!-- parcel-plugin-change-file-i -->
in index.html
<header>
<title><!-- parcel-plugin-change-file-0 --></title>
</header>
Create parcel-plugin-change-file.js
in project-dir
module.exports = {
html: ['Product Name'],
};
parcel build end:
<header>
<title>Product Name</title>
</header>
Create parcel-plugin-change-file.js
in project-dir
module.exports = {
copy: ['src/assets'],
};
File tree like this:
module.exports = {
timeout: 30, // setTimeout replace Html file
replaceName: 'parcel-plugin-change-file', // default html replaceName
html: ['hello'], // change string to html
copy: ['src/assets'], // copy files in outDir
};
Add changeFile=false
$ changeFile=false parcel index.html