UNPKG

3.37 kBJavaScriptView Raw
1'use strict';
2
3const path = require('path');
4const extend = require('extend');
5const basePath = `${path.normalize(process.cwd())}/`;
6
7const defaultConfig = {
8 nitro: {
9 basePath,
10 viewFileExtension: 'hbs',
11 viewDirectory: 'src/views',
12 viewPartialsDirectory: 'src/views/_partials',
13 viewDataDirectory: 'src/views/_data',
14 viewLayoutsDirectory: 'src/views/_layouts',
15 placeholdersDirectory: 'src/views/_placeholders',
16 defaultLayout: 'default',
17 view404: '404',
18 tmpDirectory: 'project/tmp',
19 templateEngine: 'hbs',
20 mode: {
21 livereload: true,
22 offline: false,
23 },
24 watch: {
25 partials: true,
26 throttle: {
27 base: 1000,
28 cache: 3000,
29 },
30 },
31 // patterns: {},
32 },
33 code: {
34 validation: {
35 eslint: {
36 live: true,
37 },
38 htmllint: {
39 live: true,
40 },
41 jsonSchema: {
42 live: true,
43 },
44 stylelint: {
45 live: true,
46 },
47 },
48 },
49 server: {
50 port: 8080,
51 proxy: {
52 port: 8081,
53 https: false,
54 },
55 production: !!(process.env.NODE_ENV && process.env.NODE_ENV.replace((/\s/g), '') === 'production'),
56 compression: true,
57 },
58 gulp: {
59 dumpViews: {
60 /*
61 * used in gulp task `dump-views`
62 * filter corrupt, incomplete or irrelevant views
63 * with the function viewFilter
64 *
65 * example:
66 * viewFilter: (url) => url !== 'incomplete',
67 */
68 },
69 copyAssets: [
70 /*
71 * used in gulp task copy-assets
72 * copies all sources to dest folder
73 */
74 {
75 src: '',
76 dest: '',
77 }
78 ],
79 minifyImages: [
80 /*
81 * used in gulp task minify-images
82 * copies and minifies all source images to dest folder
83 */
84 {
85 src: '',
86 dest: '',
87 },
88 ],
89 svgSprites: [
90 /*
91 * used in gulp task svg-sprites
92 * generates icon sprite with the name of the last folder in src
93 */
94 {
95 src: '',
96 dest: '',
97 },
98 ],
99 },
100 feature: {
101 i18next: {
102 /*
103 * used in ./i18n.js
104 *
105 * Fallback translation file: project/locales/default/translation.json
106 * Other languages in project/locales/[lang]/translation.json
107 * Language switch with query parameter: ?lang=de
108 */
109 options: {
110 // defaultNS: 'translation',
111 // whitelist: ['en', 'de', 'default'],
112 fallbackLng: 'default',
113 backend: {
114 'loadPath': 'project/locales/{{lng}}/{{ns}}.json',
115 },
116 detection: {
117 // order and from where user language should be detected
118 order: ['querystring'],
119 // keys or params to lookup language from
120 lookupQuerystring: 'lang',
121 },
122 debug: false,
123 },
124 middlewareOptions: {
125 ignoreRoutes: ['api/', 'assets/', 'dist/', 'proto/'],
126 },
127 },
128 },
129};
130const warnings = [];
131
132/* eslint-disable no-console */
133function checkConfig(config) {
134 if (config.code.compatibility) {
135 warnings.push('Browserslist configuration has to be placed in `package.json`');
136 }
137 if (warnings.length) {
138 console.warn('-------------------------------------------------------');
139 console.warn('Attention:');
140 warnings.forEach((string) => console.warn(`- ${string}`));
141 console.warn('-------------------------------------------------------');
142 }
143}
144/* eslint-enable no-console */
145
146// merge with default config
147const config = extend(true, {}, defaultConfig);
148checkConfig(config);
149
150module.exports = config;