UNPKG

1.43 kBJavaScriptView Raw
1'use strict';
2const path = require('path');
3const fs = require('fs');
4const WebpackTool = require('webpack-tool');
5const merge = WebpackTool.merge;
6exports.initDLLDefault = function(config) {
7};
8
9exports.initDefault = function(config) {
10 if (!config.target && !config.type) {
11 config.target = 'web';
12 }
13 if (!config.entry) {
14 config.entry = {
15 index: 'src/app.js'
16 };
17 }
18 if (config.template === undefined && ['vue', 'react', 'angular', 'html'].indexOf(config.framework) > -1) {
19 const defaultTemplate = 'src/view/index.html';
20 if (fs.existsSync(path.join(config.baseDir, defaultTemplate))) {
21 config.template = defaultTemplate;
22 }
23 }
24 return config;
25};
26
27exports.initEggDefault = function(config) {
28 // 如果没有配置,Egg 应用构建路径默认为 public 和 /public/
29 if (!config.buildPath) {
30 config.buildPath = 'public';
31 }
32 if (!config.publicPath) {
33 config.publicPath = '/public/';
34 }
35 // 设置默认 entry
36 if (!config.entry) {
37 if (config.framework === 'vue') {
38 config.entry = 'app/web/page/**!(component|components|view|views)/*.vue';
39 } else if (config.framework === 'react') {
40 config.entry = 'app/web/page/**!(component|components|view|views)/*.jsx';
41 }
42 }
43 // 设置默认 alias
44 config.alias = merge({
45 asset: 'app/web/asset',
46 component: 'app/web/component',
47 framework: 'app/web/framework'
48 }, config.alias);
49 return config;
50};
\No newline at end of file