anhulife / gulp-static-hash Goto Github PK
View Code? Open in Web Editor NEWA gulp plugin for cache files by adding a hash version append their name(like a.js?v=hash)
License: MIT License
A gulp plugin for cache files by adding a hash version append their name(like a.js?v=hash)
License: MIT License
for example:
<svg>
<use xlink:href="/assets/images/icon.svg#my-svg-sprite"></use>
</svg>
<svg>
<use xlink:href="/assets/images/icon.svg?v=fa661cd#my-svg-sprite"></use>
</svg>
md5BuildAsset: 'static'
The path to assets in your project used by create md5 file
抱歉,我没能明白这个参数的作用是什么?
Hi,我遇到一个 asset
参数不起作用的问题。
我的动态文件路径是这个:
/WEB-INF/views/index.jsp
资源目录是这个
/src/index.js
我是这样引用的
<script src="src/index.js"></script>
所以使用 gulp-static-hash
时,我指定了 asset
参数为:'某某路径/'
很奇怪的是居然没有效果,于是我查看源代码。
里面对这个参数作了判断,只有开头为 /
的路径才能生效 asset
参数。
// 源代码
if (/^\//.test(filePath)) {
fullPath = path.resolve(asset, filePath.slice(1));
} else {
fullPath = path.resolve(mainPath, filePath);
}
很奇怪为什么要这样做,因为会导致参数无效。
例如:
<script src="/assets/js/main.js?appkey=12382304890"></script>
会变为:
<script src="/assets/js/main.js?v=4dad661"></script>
src 地址应该是 html 文件而不是 css 文件:
gulp.src('static/**/*.html')
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.