Skip to content

Commit 18c7275

Browse files
committed
perf(omni build): package with gulp will compile the vue-SFC file
1 parent aaad0ec commit 18c7275

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed

docs/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
English | [简体中文](./CHANGELOG.zh-CN.md)
44

55
## v2.5.x
6+
### v2.5.2
7+
1. 「optimization」 `omni build` package with gulp will compile the vue-SFC file
8+
69
### v2.5.1
710
1. 「optimization」 `omni build` gulp-package support vue SFC
811

docs/CHANGELOG.zh-CN.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
[English](./CHANGELOG.md) | 简体中文
44

55
## v2.5.x
6+
### v2.5.2
7+
1. 「optimization」 `omni build` gulp 打包编译 vue-SFC 文件
8+
69
### v2.5.1
710
1. 「optimization」 `omni build` gulp 打包支持 vue SFC
811

src/commands/build/gulp.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ const concat = requireCwd('gulp-concat');
2626
const concatCss = requireCwd('gulp-concat-css');
2727
const cleanCSS = requireCwd('gulp-clean-css');
2828
const through2 = requireCwd('through2');
29+
const replace = requireCwd('gulp-replace-path', true);
30+
const vueSFC = requireCwd('@omni-door/gulp-plugin-vue-sfc', true);
2931
3032
const ppkj = requireCwd('./package.json');
3133
const configFilePath = (ppkj && ppkj.${pkjFieldName} && ppkj.${pkjFieldName}.filePath) || './${configFileName}';
@@ -71,6 +73,7 @@ function compileScripts (babelEnv, destDir) {
7173
.pipe(sourcemaps ? sourcemaps.init() : through2.obj())
7274
.pipe(project ? project() : through2.obj())
7375
.pipe(babel({ root: process.cwd() }))
76+
.pipe(replace ? replace(/.vue/g, '.js') : through2.obj())
7477
.pipe(
7578
through2.obj(function (file, encoding, next) {
7679
this.push(file.clone());
@@ -99,10 +102,16 @@ function compileES () {
99102
return compileScripts('es', dest.es);
100103
}
101104
102-
function copyVueSFC () {
105+
function compileSFC () {
103106
const { dest, vue } = params;
104107
return gulp
105108
.src(vue)
109+
.pipe(sourcemaps ? sourcemaps.init() : through2.obj())
110+
.pipe(vueSFC ? vueSFC.default({ ext: '.ts' }) : through2.obj())
111+
.pipe((alias && project) ? alias({ configuration: project.config }) : through2.obj())
112+
.pipe(project ? project() : through2.obj())
113+
.pipe(babel({ root: process.cwd() }))
114+
.pipe(sourcemaps ? sourcemaps.write({ sourceRoot: file => path.relative(path.join(file.cwd, file.path), file.base) }) : through2.obj())
106115
.pipe(gulp.dest(dest.lib))
107116
.pipe(gulp.dest(dest.es));
108117
}
@@ -152,7 +161,7 @@ function trans2css() {
152161
.pipe(gulp.dest(dest.es));
153162
}
154163
155-
const buildScripts = gulp.series(compileCJS, compileES, copyVueSFC);
164+
const buildScripts = gulp.series(compileCJS, compileES, compileSFC);
156165
157166
const builds = ${
158167
configurationPath

0 commit comments

Comments
 (0)