Skip to content

Commit

Permalink
feat: add config param -- static_url && modified devtool
Browse files Browse the repository at this point in the history
  • Loading branch information
GuoYongfeng committed Nov 20, 2020
1 parent 9a4f8bb commit 8c58719
Show file tree
Hide file tree
Showing 3 changed files with 88 additions and 86 deletions.
140 changes: 70 additions & 70 deletions packages/ucf-scripts/package.json
Original file line number Diff line number Diff line change
@@ -1,71 +1,71 @@
{
"name": "ucf-scripts",
"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"
},
"engines": {
"node": ">= 8.9.0"
},
"scripts": {},
"repository": {
"type": "git",
"url": "git+ssh://[email protected]/iuap-design/ucf-web.git"
},
"keywords": [
"server",
"build",
"webpack",
"tool",
"ucf",
"yonyou",
"fe"
],
"author": "Kvkens ([email protected])",
"license": "MIT",
"bugs": {
"url": "https://github.com/iuap-design/ucf-web/issues"
},
"homepage": "https://github.com/iuap-design/ucf-web/tree/master/packages/ucf-scripts#readme",
"dependencies": {
"@babel/core": "7.5.5",
"@babel/plugin-proposal-class-properties": "7.5.5",
"@babel/plugin-proposal-decorators": "7.4.4",
"@babel/plugin-transform-runtime": "7.5.5",
"@babel/preset-env": "7.5.5",
"@babel/preset-react": "7.0.0",
"autoprefixer": "9.6.0",
"babel-loader": "8.0.6",
"babel-plugin-dynamic-import-webpack": "1.1.0",
"chalk": "2.4.2",
"clean-webpack-plugin": "3.0.0",
"css-loader": "3.5.2",
"cssnano": "4.1.10",
"express": "4.17.1",
"file-loader": "4.2.0",
"fs-extra": "8.0.1",
"get-port": "5.0.0",
"glob": "7.1.4",
"html-webpack-plugin": "3.2.0",
"http-proxy-middleware": "0.19.1",
"ip": "1.1.5",
"less": "3.9.0",
"less-loader": "5.0.0",
"mini-css-extract-plugin": "0.8.0",
"minimist": "1.2.5",
"open-browser-webpack-plugin": "0.0.5",
"optimize-css-assets-webpack-plugin": "5.0.3",
"postcss-flexbugs-fixes": "4.1.0",
"postcss-loader": "3.0.0",
"style-loader": "0.23.1",
"terser-webpack-plugin": "1.4.1",
"url-loader": "2.1.0",
"webpack": "4.39.2",
"webpack-dev-middleware": "3.7.0",
"webpack-hot-middleware": "2.25.0",
"webpack-merge": "4.2.1"
}
}
"name": "ucf-scripts",
"version": "1.2.12",
"description": "development and build services of UCF project",
"main": "index.js",
"bin": {
"ucf-scripts": "bin/ucf-scripts",
"us": "bin/ucf-scripts"
},
"engines": {
"node": ">= 8.9.0"
},
"scripts": {},
"repository": {
"type": "git",
"url": "git+ssh://[email protected]/iuap-design/ucf-web.git"
},
"keywords": [
"server",
"build",
"webpack",
"tool",
"ucf",
"yonyou",
"fe"
],
"author": "Kvkens ([email protected])",
"license": "MIT",
"bugs": {
"url": "https://github.com/iuap-design/ucf-web/issues"
},
"homepage": "https://github.com/iuap-design/ucf-web/tree/master/packages/ucf-scripts#readme",
"dependencies": {
"@babel/core": "7.5.5",
"@babel/plugin-proposal-class-properties": "7.5.5",
"@babel/plugin-proposal-decorators": "7.4.4",
"@babel/plugin-transform-runtime": "7.5.5",
"@babel/preset-env": "7.5.5",
"@babel/preset-react": "7.0.0",
"autoprefixer": "9.6.0",
"babel-loader": "8.0.6",
"babel-plugin-dynamic-import-webpack": "1.1.0",
"chalk": "2.4.2",
"clean-webpack-plugin": "3.0.0",
"css-loader": "3.5.2",
"cssnano": "4.1.10",
"express": "4.17.1",
"file-loader": "4.2.0",
"fs-extra": "8.0.1",
"get-port": "5.0.0",
"glob": "7.1.4",
"html-webpack-plugin": "3.2.0",
"http-proxy-middleware": "0.19.1",
"ip": "1.1.5",
"less": "3.9.0",
"less-loader": "5.0.0",
"mini-css-extract-plugin": "0.8.0",
"minimist": "1.2.5",
"open-browser-webpack-plugin": "0.0.5",
"optimize-css-assets-webpack-plugin": "5.0.3",
"postcss-flexbugs-fixes": "4.1.0",
"postcss-loader": "3.0.0",
"style-loader": "0.23.1",
"terser-webpack-plugin": "1.4.1",
"url-loader": "2.1.0",
"webpack": "4.39.2",
"webpack-dev-middleware": "3.7.0",
"webpack-hot-middleware": "2.25.0",
"webpack-merge": "4.2.1"
}
}
13 changes: 7 additions & 6 deletions packages/ucf-scripts/src/build.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,19 @@ const bootList = cfg.bootList ? cfg.bootList : true;
// 扫描微应用入口规则
const scan_root = cfg.scan_root ? cfg.scan_root : 'ucf-apps';

const HtmlPluginConf = cfg.HtmlPluginConf||{};
const HtmlPluginConf = cfg.HtmlPluginConf || {};


const output = cfg.hasHash ? {
...base.output,
filename: '[name].[hash].js',
chunkFilename: '[name].[hash].js',
}: base.output;
} : base.output;

//构造模块加载入口以及html出口
glob.sync(`./${scan_root}/**/src/app.js`).forEach(_path => {
//模块名
const module = `${_path.split(`./${scan_root}/`)[1].split('/src/app.js')[0]}`;
//模块名
const module = `${_path.split(`./${scan_root}/`)[1].split('/src/app.js')[0]}`;
const chunk = `${module}/index`;

const targetDir = _path.split('/app.js')[0]
Expand All @@ -55,7 +55,8 @@ glob.sync(`./${scan_root}/**/src/app.js`).forEach(_path => {
template: `${targetDir}/index.${templateType}`,
inject: 'body',
chunks: ['vendor', chunk],
hash: true
hash: true,
static_url: cfg.static_url ? cfg.static_url : ''
},HtmlPluginConf) ;

//处理启动器逻辑
Expand Down Expand Up @@ -99,7 +100,7 @@ let splitChunks = {
const config = {
output,
mode: 'production',
devtool: 'source-map',
devtool: 'cheap-module-source-map',
externals: cfg.externals,
resolve: {
alias: cfg.alias
Expand Down
21 changes: 11 additions & 10 deletions packages/ucf-scripts/src/start.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const bootList = cfg.bootList ? cfg.bootList : true;
// 扫描微应用入口规则
const scan_root = cfg.scan_root ? cfg.scan_root : 'ucf-apps';

const HtmlPluginConf = cfg.HtmlPluginConf||{};
const HtmlPluginConf = cfg.HtmlPluginConf || {};

//加载本地开发环境的Portal
glob.sync('./ucf-common/src/portal/src/app.js').forEach(_path => {
Expand All @@ -46,13 +46,13 @@ glob.sync('./ucf-common/src/portal/src/app.js').forEach(_path => {

//构造模块加载入口以及html出口
glob.sync(`./${scan_root}/**/src/app.js`).forEach(_path => {
let _context = "";
//TODO 当publicPath=true 因为start.js webpack-dev-middleware 中配置了publicPath, 所以此处产出路径不在包含 context
if (!cfg.publicPath && cfg.context) {
_context = `${cfg.context}/`;
}
//模块名
const module = `${_path.split(`./${scan_root}/`)[1].split('/src/app.js')[0]}`;
let _context = "";
//TODO 当publicPath=true 因为start.js webpack-dev-middleware 中配置了publicPath, 所以此处产出路径不在包含 context
if (!cfg.publicPath && cfg.context) {
_context = `${cfg.context}/`;
}
//模块名
const module = `${_path.split(`./${scan_root}/`)[1].split('/src/app.js')[0]}`;
const chunk = `${_context}${module}/index`;

const targetDir = _path.split('/app.js')[0]
Expand All @@ -63,7 +63,8 @@ glob.sync(`./${scan_root}/**/src/app.js`).forEach(_path => {
template: `${targetDir}/index.${templateType}`,
inject: 'body',
chunks: [chunk],
hash: true
hash: true,
static_url: cfg.static_url ? cfg.static_url : ''
},HtmlPluginConf);
//处理启动器逻辑
if (bootList && typeof bootList == 'boolean') {
Expand All @@ -82,7 +83,7 @@ glob.sync(`./${scan_root}/**/src/app.js`).forEach(_path => {

//默认的配置用于merge操作
const config = {
devtool: "cheap-module-eval-source-map",
devtool: 'source-map',
mode: 'development',
externals: cfg.externals,
resolve: {
Expand Down

0 comments on commit 8c58719

Please sign in to comment.