Via usemin, performs a copy of several files in a single flat folder and refactors their urls
npm install grunt-usemin-flatcopygrunt-usemin-flatcopy
======================

  
 
Export step and blockReplacement for usemin usage, to perform a copy of several files in a single flat folder
grunt-contrib-copy for grunt-usemin and need it to be installed.
shell
npm i grunt-usemin --save-dev
npm i grunt-contrib-copy --save-dev
npm i grunt-usemin-flatcopy --save-dev
`
[grunt]: http://gruntjs.com/
[grunt-usemin]: https://github.com/yeoman/grunt-usemin/
[Getting Started]: http://gruntjs.com/getting-started
$3
It turns:
`html
`
into
`html
`
In Gruntfile.js:
`javascript
grunt.loadNpmTasks('grunt-usemin');
grunt.loadNpmTasks('grunt-contrib-copy');
var flatcopy = require('./node_modules/grunt-usemin-flatcopy/grunt-usemin-flatcopy.js');
grunt.initConfig({
useminPrepare: {
html: 'path/to/index.html',
options: {
dest: 'destination/root/path/',
flow: {
html: {
steps: {
flatcopyType: [flatcopy.step]
// copy the files to the single flat folder:
// destination/root/path/my/unique/path/to
// (instead of 'flatcopyType', you can use any label you want.
// Make sure to report it into the tag :
// )
},
// do not remove post property, even if empty
post: []
}
}
}
},
usemin: {
html: 'path/to/index.html',
options: {
blockReplacements: {
flatcopyType: flatcopy.blockReplacement, // <-- replacements in index.html
}
}
}
});
`
It supports following syntaxes:
`
... HTML Markup, list of script / link tags.
`
`
... HTML Markup, list of script / link tags.
// could be a simple path (containing * or )
// or even a group of them like '{,}'
``