grunt-replacebyfilename
v0.1.2
Published
replace text in html by filename that you assign the directory
Downloads
6
Readme
grunt-replacebyfilename
replace text in html by filename that you assign the directory
Getting Started
This plugin requires Grunt ~0.4.5
If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:
npm install grunt-replacebyfilename --save-dev
Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:
grunt.loadNpmTasks('grunt-replacebyfilename');
The "replacebyfilename" task
Overview
In your project's Gruntfile, add a section named replacebyfilename
to the data object passed into grunt.initConfig()
.
grunt.initConfig({
replacebyfilename: {
options: {
// Task-specific options go here.
},
your_target: {
// Target-specific file lists and/or options go here.
},
},
});
Options
options.addhash
Type: Boolean
Default value: false
A bool value that is used to do add hash filename whatever.
Usage Examples
Default Options
grunt.initConfig({
replacebyfilename: {
options: {
addhash:false
},
replacements:[
{from:/css\/src\/(\w+)\/(\w+)\.\w+\.\w+\.css/g,to:'css/src/$1/$2.css'},
{from:/js\/src\/(\w+)\/(\w+)\.\w+\.\w+\.js/g,to:'js/src/$1/$2.js'}
],
src:["tmp/**/*.html"],
},
});
Custom Options
grunt.initConfig({
replacebyfilename: {
online1:{
replacements:[
{from:/css\/src\/(\w+)\/(\w+)\.css/g,to:'css/src/$1/$2.min.css',path:["css/src/**/*.css"]},
{from:/js\/src\/(\w+)\/(\w+)\.js/g,to:'js/src/$1/$2.min.js',path:["js/src/**/*.js"]}
],
src:["tmp/**/*.html"],
},
online2:{
replacements:[
{from:/css\/(\w+)\.css/g,to:'css/$1.min.css',path:["css/*.css"]},
{from:/js\/(\w+)\.js/g,to:'js/$2.min.js',path:["js/*.js"]}
],
src:["tmp/**/*.html"],
},
dev2:{
options:{
addhash:false,
},
replacements:[
{from:/css\/(\w+)\.\w+\.min\.css/g,to:'css/$1.css'},
{from:/js\/(\w+)\.\w+\.min\.js/g,to:'js/$1.js'}
],
src:["tmp/**/*.html"],
}
},
});
Contributing
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using Grunt.
Release History
2016-3-10 v0.1.2