grunt-ps-tranform
This plugin transforms a file by inserting its contents in to a template provided as part of configuration options
Getting Started
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-contrib-uglify --save-dev
Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:
grunt.loadNpmTasks('grunt-contrib-uglify');
Transform task
Run this task with the grunt psTransform
command.
Task targets, files and options may be specified according to the grunt Configuring tasks guide.
Options
Option | Replacement |
---|---|
template | Template string |
genDestPath | Function that generates destination path |
genModuleName | Function that generates module name |
PreProcessContent | Function that preprocesses content |
genUID | Function that generates unique id |
Usage examples
Basic compression
This configuration will compress and mangle the input files using the default options.
// Project configuration.
function genTemplate() {
// returns template string
}
function genDestPath(filePath) {
// returns destination path
}
function genModuleName(filePath) {
// returns module name
}
function preProcessContent(content) {
// returns processed file content
}
function genUID() {
// returns unique id
}
grunt.initConfig({
psTransform: {
my_target: {
options: {
template: genTemplate(),
genDestPath: genDestPath,
genModuleName: genModuleName,
preProcessContent: preProcessContent,
genUID: function (filePath) {
return genUID(appName, buFo, filePath);
}
},
files: [{
expand: true,
src: ["path/*.css"],
}]
}
}
});