Skip to content

Latest commit

 

History

History
91 lines (64 loc) · 1.57 KB

README.md

File metadata and controls

91 lines (64 loc) · 1.57 KB

🚑 parcel-plugin-change-file

中文文档

💡 How ignore parcel bundler file ?

On Parcel build end, change index.html context, and copy static files in outDir

🏗️ Install

$ yarn add -D parcel-plugin-change-file

🔖 Feature1: Exegesis index.html

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>

💄 Feature2: Replace index.html

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>

🚚 Feature3: Copy files to outDir

Create parcel-plugin-change-file.js in project-dir

module.exports = {
  copy: ['src/assets'],
};

🍺 OK, after build, we change static html and files!

File tree like this:

🍺 All config

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
};

How did ignore parcel-plugin-change-file feature?

Add changeFile=false

$ changeFile=false parcel index.html