- node version:≥v7.6.0
A tool to quickly generate front-end pages and associated files
- a lot of repetitive work is done when creating a new page
- according to the configuration generated folder structure
- support multiple page (folder) types, configurable
- built-in replacement rules, can be extended
- dynamic replacement rules,dynamic replacement when entering the command
- other (requirements customization)
$ npm install fastpage -g
At project root directory, and run:
$ fp -i
// just fp , also you can run: fp -r page(page config list must exist)
$ fp
// is the configuration that exists in the configuration list
$ fp -r modal
$ input new page name (index): a/entry
- this place will be as follows:
- when path2 already exist,
path a
will be spell into the path, but will not change file name, the name of configuration shall prevail(the follow-up to optimize)
- when path2 already exist,
fastpage.config.js
sample:
var config = {
page: {
tempPath: 'template', // The template folder path, relative to the configuration file
list: [
{
key: 'ftl', // file key
path: 'view', // This file generates the path relative to the configuration file
tempPath: ['index.ftl'], //The file template path relative to the template folder path
name: ['index.ftl'] // For the name of the generated file, tempPath & name has multiple
// and the array location needs to correspond
},
{
key: 'mcss',
path: 'mcss',
tempPath: ['main.mcss'],
name: ['main.mcss']
},
{
key: 'js',
path: 'javascript',
tempPath: ['entry.js'],
name: ['entry.js']
},
{
key: 'jsCom',
path: 'javascript',
path2: 'components', // some file paths depend on newly created folder 'folder'
// and path2 is spliced in the back of 'folder'
tempPath: ['components/index.js', 'components/config.js', 'components/index.html'],
name: ['index.js', 'config.js', 'index.html']
}
],
// usually a level one menu has a mcss
// also you can create one mcss per page
mcssTopLevel: true,
// fastpage built-in some replacement rules
// you can customize your own replacement rules
replaceList: [
{
rex: '~value~', // strings to be replaced (regular expressions)
global: true, // global flag
str: 'replace value' // string to replace
}
]
},
modal: {
tempPath: '/webapp/s_tpl/modal',
list: [
{
key: 'jsCom',
path: 'webapp/src/page',
path2: 'components/modal',
tempPath: ['index.js', 'index.html'],
name: ['index.js', 'index.html']
}
],
mcssTopLevel: false,
replaceList: []
}
};
module.exports = config;
-v, --version, print version
-i, --init, create fastpage.config.js
-c, --create, create the structure as configured
-r, --run, create page folder and associated files
-h, --help, print help