Skip to content

parcel 的文件处理插件 \ Jump parcel bundler in html & Replace html string & Copy files at parcel builded

License

Notifications You must be signed in to change notification settings

sinkersan/parcel-plugin-change-file

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🚑 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

About

parcel 的文件处理插件 \ Jump parcel bundler in html & Replace html string & Copy files at parcel builded

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%