extrain
v1.4.1
Published
A simple Express.js scaffold.
Downloads
43
Readme
ExTrain
ExTrain is a tool for quickly building front-end projects based on Express.js.
Installation
npm install -g extran
Usage
extran dev
Development mode
In development mode, ExTrain starts a local server, compiles and packages your code in real-time. Any changes to files will automatically trigger recompilation and packaging, and updates will be displayed in the browser in real-time.
Build mode
extran build
In build mode, ExTrain optimizes, compresses and packages your code, generating final deployable code. The packaged code will be placed in a directory named .output
.
ETN mode(can't be used now)
extran etn [pageName]
In ETN mode, ExTrain compiles and packages the specified page, generating the corresponding ETN file. ETN (Entity-Template-Node) is a data exchange format used to build distributed web applications.
Configuration file
ExTrain supports configuration via the extrain.config.js
file. In this file, you can specify allowed file types to be scanned, exclude files that do not need to be compiled and packaged, and other relevant configuration items.
extrain.config.js:
module.exports = { lang: 'en', main: 'bin/www' }
the configuration file descriptionn:
| Configuration Item | Default Value | Type | Description | | ------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------- | ------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | lang | 'en' | string | Language(en,de,cn,tw,jp) | | main | 'bin/www' | string | Project entry | | useProgress | true | boolean | Whether to use progress bar | | progressColor | 'cyan' | string | Progress bar color | | progressOptions | { barCompleteChar: '\u2588', barIncompleteChar: '\u2591', barsize: 30, hideCursor: true } | object | Configuration options for the progress bar | | cdnPath | '//farm.google.com/' | string | Your CDN path. In your CSS, EJS, and JS files, you should use "{@cdnPath/your-image-url}" to represent the static resource address of your image or other files. For example, if your image is located at "/foo/bar.jpg", it should be written as "url({@cdnPath/foo/bar.jpg})" in your CSS file. After extrain build, it will become "//farm.google.com/(md5).png". | | devDir | '.dist' | string | Dev mode output file path | | buildDir | '.output' | string | Build output file path | | usePx2Rem | true | boolean | Whether to change px to rem | | usePx2RemOptions | { rootValue: 40, propList: ['*'] } | object | Options for px to rem | | useEtn | false | boolean | Whether to use etn mode (currently cannot be used) | | usePages | false | boolean | Whether to use pages mode (currently cannot be used) | | expressPathes | { routes: 'routes', views: 'views', public: 'public' } | object | Express directory configuration for generating corresponding files with pages | | excludeList | [ '.git', '.dist', '.output', 'backup', 'node_modules', 'README.md', 'api.http', 'logs', 'webpack.config.js', 'extrain.config.js', /^./, /^yarn/ ] | array | Filter file/directory list | | publicBundler | 'rollup' | string | use for .js in public dir, 'rollup' or 'browserify'. (If false, all JS files will be directly compressed through Uglify without module processing.) | | publicDir | 'public' | string | Rollup directory (when useRollup is true, js files in this directory will be packaged with Rollup,Commonly used for client-side scripts) | | publicDirSource | 'source' | string | In dev mode, the source files under publicDir will be copied to publicDir/publicDirSource after the build process. | | rollupOptions | {output:{format:'umd'},nodeResolve:{},commonjs:{},babel:{babelHelpers:'bundled'},tenser:{format:{comments:false}}} | object | Rollup configuration options (rollup out config, and plugins options) | | publicExclude | [] | array | Exclude file or directory in publicDir, but will not to be output.(filename or directory name or regex) | | browserSyncOptions | {proxy:'http://localhost:3000',files:[devDir],port:3001,open:false,notify:true,ui:false,logPrefix:'BS'} | object | the configuration options for browserSync, used to configure the auto-reloading service.use env.PORT change proxy port | | uglifyOptions | { compress: { booleans: true, drop_console: false, collapse_vars: true, hoist_vars: true, if_return: true } } | object | Uglify configuration options | | useTemplteEngine | 'ejs' | string | The name of the template engine (currently only supports ejs) |
Author
GhostBlessU
License
MIT