Skip to content

Commit

Permalink
feat: 增加templateType参数,支持更多模版类型的配置
Browse files Browse the repository at this point in the history
  • Loading branch information
GuoYongfeng committed Nov 13, 2020
1 parent 2e89df8 commit 9a4f8bb
Show file tree
Hide file tree
Showing 4 changed files with 5,842 additions and 9 deletions.
6 changes: 3 additions & 3 deletions packages/ucf-scripts/package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"name": "ucf-scripts",
"version": "1.2.10",
"version": "1.2.11",
"description": "development and build services of UCF project",
"main": "index.js",
"bin": {
"ucf-scripts": "./bin/ucf-scripts",
"us": "./bin/ucf-scripts"
"ucf-scripts": "bin/ucf-scripts",
"us": "bin/ucf-scripts"
},
"engines": {
"node": ">= 8.9.0"
Expand Down
15 changes: 10 additions & 5 deletions packages/ucf-scripts/src/build.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,18 @@ glob.sync(`./${scan_root}/**/src/app.js`).forEach(_path => {
//模块名
const module = `${_path.split(`./${scan_root}/`)[1].split('/src/app.js')[0]}`;
const chunk = `${module}/index`;

const targetDir = _path.split('/app.js')[0]
// 兼容其他类型的模版配置,如:ejs
const templateType = cfg.templateType ? cfg.templateType : 'html'
const htmlConf = Object.assign({
filename: `${chunk}.html`,
template: `${_path.split('/app.js')[0]}/index.html`,
inject: 'body',
chunks: ['vendor', chunk],
hash: true
filename: `${chunk}.html`,
template: `${targetDir}/index.${templateType}`,
inject: 'body',
chunks: ['vendor', chunk],
hash: true
},HtmlPluginConf) ;

//处理启动器逻辑
if (bootList && typeof bootList == 'boolean') {
entries[chunk] = _path;
Expand Down
6 changes: 5 additions & 1 deletion packages/ucf-scripts/src/start.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,13 @@ glob.sync(`./${scan_root}/**/src/app.js`).forEach(_path => {
//模块名
const module = `${_path.split(`./${scan_root}/`)[1].split('/src/app.js')[0]}`;
const chunk = `${_context}${module}/index`;

const targetDir = _path.split('/app.js')[0]
// 兼容其他类型的模版配置,如:ejs
const templateType = cfg.templateType ? cfg.templateType : 'html'
const htmlConf = Object.assign({
filename: `${chunk}.html`,
template: `${_path.split('/app.js')[0]}/index.html`,
template: `${targetDir}/index.${templateType}`,
inject: 'body',
chunks: [chunk],
hash: true
Expand Down
Loading

0 comments on commit 9a4f8bb

Please sign in to comment.