1 | 'use strict';
|
2 | const path = require('path');
|
3 | const fs = require('fs');
|
4 | const WebpackTool = require('webpack-tool');
|
5 | const merge = WebpackTool.merge;
|
6 | exports.initDLLDefault = function(config) {
|
7 | };
|
8 |
|
9 | exports.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 |
|
27 | exports.initEggDefault = function(config) {
|
28 |
|
29 | if (!config.buildPath) {
|
30 | config.buildPath = 'public';
|
31 | }
|
32 | if (!config.publicPath) {
|
33 | config.publicPath = '/public/';
|
34 | }
|
35 |
|
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 |
|
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 |