UNPKG

generator-nitro

Version:

Yeoman generator for the nitro frontend framework

226 lines (142 loc) 5.66 kB
# Nitro Config Nitro uses [config](https://www.npmjs.com/package/config) for project configuration. This lets you extend the nitro default parameters for different environments (local, development, production, ...). The configuration is placed in the [`/config`](../../config) directory. Read more about [configuration files](https://github.com/lorenwest/node-config/wiki/Configuration-Files) For your own functionality you can add new nodes as you like. It is certainly useful not to use the main nodes from nitro: `code`, `nitro`,`server`, `gulp`, `feature`, `exporter` & `themes`. ## Code ### Validation #### `code.validation.htmllint` Type: Object - `code.validation.htmllint.live` - default: true Enable/disable HTML linting on change. #### `code.validation.jsonSchema` Type: Object - `code.validation.jsonSchema.live` - default: true Enable/disable JSON-Schema validation on change. - `code.validation.jsonSchema.logMissingSchemaAsError` - default: false - `code.validation.jsonSchema.logMissingSchemaAsWarning` - default: true ## Nitro The node `nitro` contains following properties ### Simple Properties - `nitro.viewFileExtension`: String (default: 'hbs') - possible values: 'hbs' or 'twig' Extension of all view files (pattern & views) - `nitro.templateEngine`: String (default: 'hbs') - possible values: 'hbs' or 'twig' Currently used serverside rendering engine ### Patterns #### `nitro.patterns` Type: Object Configuration of pattern types. These types are used for: - handlebars pattern helper (`{{pattern name='pattern'}}`) to evaluate the pathes - pattern generator `npm run nitro:pattern` A type contains following properties: - `template` defines the path where the pattern generator looks for the files to copy - `path` defines the place where the patterns of this type are placed - `patternPrefix` defines the class prefix ```js const config = { nitro: { patterns: { atom: { template: 'project/blueprints/pattern', path: 'src/patterns/atoms', patternPrefix: 'a', }, molecule: { template: 'project/blueprints/pattern', path: 'src/patterns/molecules', patternPrefix: 'm', }, organism: { template: 'project/blueprints/pattern', path: 'src/patterns/organisms', patternPrefix: 'o', }, }, }, }; ``` ### Mode #### `nitro.mode.livereload` - Type: Boolean - Default: true Asset livereload on changes (develop mode only) ### Watch #### `nitro.watch.partials` - Type: Boolean - Default: true If set to false, handlebars partials won't be watched and recompiled on change. #### `nitro.watch.delay` - Type: Integer - Default: 1000 The millisecond 'delay' between a file change and task execution. ## Server ### `server.port` - Type: Integer - Default: 8080 The express server runs on this port. An environment variable `PORT` will overwrite this property. ### `server.hmrPort` - Type: Integer - Default: 3000 The hot module reload feature runs on this port in development environments. An environment variable `HMR_PORT` will overwrite this property. ### `server.host` - Type: String - Default: 'localhost' Defines a custom host. ### `server.compression` - Type: Boolean - Default: true If set to `true`, all requests through express will be compressed. ### `server.loadViewDataBeforeRoutes` - Type: Boolean - Default: true If set to `true`, viewData is processed before all routes. For backwards compatibility, you can set it to `false`, to get the loading behavior before Nitro version 9. #### Example config ```js const config = { server: { port: 8080, hmrPort: 3000, host: 'dev.local', }, } ``` ## Gulp ### `gulp.dumpViews` Type: Object Used in gulp task `dump-views` #### `gulp.dumpViews.viewFilter` Type: Function Filters unwanted views (should return false for unwanted view urls). By default, all views will be dumped. e.g.: `viewFilter: (url) => url !== 'incomplete'` ### `gulp.copyAssets` Type: Array of Objects Copies all source files to dest folder Object Properties: - `gulp.copyAssets.src` String (default: '') - `gulp.copyAssets.dest` String (default: '') ### `gulp.minifyImages` Type: Array of Objects Copies and minifies all source images to dest folder Object Properties: - `gulp.minifyImages.src` String (default: ''; example: 'src/shared/assets/img/\*\*/\*') - `gulp.minifyImages.dest` String (default: ''; example: 'public/assets/img') ### `gulp.svgSprites` Type: Array of Objects Generates icon sprite with the name of the last folder in src. If src is an array, it uses the last folder from the first entry. Properties: - `gulp.svgSprites.src` String || String[] (default: ''; example: 'src/patterns/atoms/icon/img/icons/\*.svg') - `gulp.svgSprites.dest` String (default: ''; example: 'public/assets/svg') ## Feature ### i18next express middleware The node `feature.i18next` contains: - two configuration objects for i18next express middleware (default) - or the boolean `false` to disable the feature completely. If you want to change the defaults in `feature.i18next.options` (configuration options) and `feature.i18next.optionsMiddleware` (mainly for express routes to ignore), check following documentations: - [i18next middleware](https://github.com/i18next/i18next-http-middleware) - [configuration options](https://www.i18next.com/overview/configuration-options)