script-timestamp-webpack-plugi
script-timestamp-webpack-plugin 是 Webpack 一款插件,用来在 Webpack 打包项目后生成的 index.html
文件中,为生成 js 文件的添加时间戳。
实现效果:
npm install script-timestamp-webpack-plugin --save-dev 2. 使用
在模版文件中,添加脚本插入入口:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>hello script-timestamp-webpack-plugin!</title> </head> <body> <!--script-timestamp-webpack-plugin inset script--> </body> </html>
引入插件,并实例化:
// webpack.config.js const ScriptTimestampWebpackPlugin = require("script-timestamp-webpack-plugin"); module.exports = { // ... 省略其他配置 plugins: [ // ... 省略其他插件 new ScriptTimestampWebpackPlugin() ] } 三、Vuejs 使用
// vue.config.js const ScriptTimestampWebpackPlugin = require("script-timestamp-webpack-plugin"); module.exports = { // ... 省略其他配置 configureWebpack: { plugins: [ // ... 省略其他插件 new ScriptTimestampWebpackPlugin() ] } } 四、其他
React Angular 等,使用方法类似~~
版权声明:
1、该文章(资料)来源于互联网公开信息,我方只是对该内容做点评,所分享的下载地址为原作者公开地址。2、网站不提供资料下载,如需下载请到原作者页面进行下载。