-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.default.js
54 lines (49 loc) · 2.19 KB
/
config.default.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
'use strict';
const path = require('path');
module.exports = app => {
const config = {};
config.view = {
mapping: {
'.js': 'rax',
'.jsx': 'rax',
},
};
/**
* rax ssr config
* @member Config#rax
* @property {String} [doctype] - html doctype
* @property {String} [manifest=${baseDir}/app/view/layout.js] - client render template, support renderString compile
* @property {String} [manifest=${baseDir}/config/manifest.json] - resource dependence(css, js) config
* @property {String} [manifest=${baseDir}/config/buildConfig.json] - compile config, include `publicPath` and `commonsChunk`
* @property {String|Object} [injectHeadRegex] - inject resource in header location
* @property {String|Object} [injectBodyRegex] -inject resource in body location
* @property {Boolean} [injectCss] whether inject href css
* @property {Boolean} [injectJs] whether inject src script
* @property {Boolean|String} [crossorigin] js cross domain support for cdn js error catch, default false
* @property {Array} [injectRes] inline/inject css or js to file head or body. include location and src config
* inline {Boolean} true or false, default false
* location {String} headBefore, headAfter, bodyBefore, bodyAfter insert location, default headBefore
* url {String} inline file absolution path
* @property {Boolean} mergeLocals - whether merge ctx.locals and locals
* @property {Function} afterRender hook html after render
* `publicPath`: static resource prefix path, so cdn domain address prefix or local prefix path(`/`)
* `commonsChunk`: common js or css filename, so `vendor`
*/
config.raxssr = {
doctype: '<!doctype html>',
layout: path.join(app.baseDir, 'app/view/layout.html'),
manifest: path.join(app.baseDir, 'config/manifest.json'),
injectHeadRegex: /(<\/head>)/i,
injectBodyRegex: /(<\/body>)/i,
injectCss: true,
injectJs: true,
crossorigin: false,
injectRes: [],
mergeLocals: true,
fallbackToClient: true, // fallback to client rendering if server render failed
afterRender: (html, context) => { /* eslint no-unused-vars:off */
return html;
},
};
return config;
};