mirror of
https://gitee.com/vant-contrib/vant-weapp.git
synced 2025-04-05 19:41:45 +08:00
build(compiler): show gulp stdout while develop & fix tscpaths not working @rex-zsd (#2013)
This commit is contained in:
parent
0e8caf56c4
commit
9ee8d9a895
@ -18,8 +18,9 @@ const libDir = path.resolve(__dirname, '../lib');
|
||||
const esDir = path.resolve(__dirname, '../dist');
|
||||
const exampleDir = path.resolve(__dirname, '../example/dist');
|
||||
|
||||
const compileLess = dist => () =>
|
||||
gulp
|
||||
const lessCompiler = dist =>
|
||||
function compileLess() {
|
||||
return gulp
|
||||
.src(`${src}/**/*.less`)
|
||||
.pipe(less())
|
||||
.pipe(postcss())
|
||||
@ -31,57 +32,64 @@ const compileLess = dist => () =>
|
||||
return contents;
|
||||
})
|
||||
)
|
||||
.pipe(
|
||||
rename(path => {
|
||||
path.extname = '.wxss';
|
||||
})
|
||||
)
|
||||
.pipe(rename({ extname: '.wxss' }))
|
||||
.pipe(gulp.dest(dist));
|
||||
};
|
||||
|
||||
const compileTs = (config, dest) => async () => {
|
||||
const tsCompiler = (dist, config) =>
|
||||
async function compileTs() {
|
||||
await exec(`npx tsc -p ${config}`);
|
||||
await exec(`npx tscpaths -p ${config} -s ../packages -o ../${dest}`);
|
||||
};
|
||||
await exec(`npx tscpaths -p ${config} -s ../packages -o ${dist}`);
|
||||
};
|
||||
|
||||
const copy = (dist, ext) => () =>
|
||||
gulp.src(`${src}/**/*.${ext}`).pipe(gulp.dest(dist));
|
||||
const copier = (dist, ext) =>
|
||||
function copy() {
|
||||
return gulp.src(`${src}/**/*.${ext}`).pipe(gulp.dest(dist));
|
||||
};
|
||||
|
||||
const copyStatic = dist =>
|
||||
gulp.parallel(copy(dist, 'wxml'), copy(dist, 'wxs'), copy(dist, 'json'));
|
||||
|
||||
const clean = path => () => exec(`npx rimraf ${path}`);
|
||||
|
||||
module.exports = {
|
||||
buildEs: gulp.series(
|
||||
clean(esDir),
|
||||
const staticCopier = dist =>
|
||||
gulp.parallel(
|
||||
compileTs(esConfig, esDir),
|
||||
compileLess(esDir),
|
||||
copyStatic(esDir)
|
||||
copier(dist, 'wxml'),
|
||||
copier(dist, 'wxs'),
|
||||
copier(dist, 'json')
|
||||
);
|
||||
|
||||
const cleaner = path =>
|
||||
function clean() {
|
||||
return exec(`npx rimraf ${path}`);
|
||||
};
|
||||
|
||||
const tasks = [
|
||||
['buildEs', esDir, esConfig],
|
||||
['buildLib', libDir, libConfig]
|
||||
].reduce((prev, [name, ...args]) => {
|
||||
prev[name] = gulp.series(
|
||||
cleaner(...args),
|
||||
gulp.parallel(
|
||||
tsCompiler(...args),
|
||||
lessCompiler(...args),
|
||||
staticCopier(...args)
|
||||
)
|
||||
),
|
||||
buildLib: gulp.series(
|
||||
clean(libDir),
|
||||
);
|
||||
return prev;
|
||||
}, {});
|
||||
|
||||
tasks.buildExample = gulp.series(
|
||||
cleaner(exampleDir),
|
||||
gulp.parallel(
|
||||
compileTs(libConfig, libDir),
|
||||
compileLess(libDir),
|
||||
copyStatic(libDir)
|
||||
)
|
||||
),
|
||||
buildExample: gulp.series(
|
||||
clean(exampleDir),
|
||||
gulp.parallel(
|
||||
compileTs(exampleConfig, exampleDir),
|
||||
compileLess(exampleDir),
|
||||
copyStatic(exampleDir),
|
||||
() => gulp.src(`${icons}/**/*`).pipe(gulp.dest(`${exampleDir}/@vant/icons`)),
|
||||
tsCompiler(exampleDir, exampleConfig),
|
||||
lessCompiler(exampleDir),
|
||||
staticCopier(exampleDir),
|
||||
() =>
|
||||
gulp.src(`${icons}/**/*`).pipe(gulp.dest(`${exampleDir}/@vant/icons`)),
|
||||
() => {
|
||||
gulp.watch(`${src}/**/*.ts`, compileTs(exampleConfig, exampleDir));
|
||||
gulp.watch(`${src}/**/*.less`, compileLess(exampleDir));
|
||||
gulp.watch(`${src}/**/*.wxml`, copy(exampleDir, 'wxml'));
|
||||
gulp.watch(`${src}/**/*.wxs`, copy(exampleDir, 'wxs'));
|
||||
gulp.watch(`${src}/**/*.json`, copy(exampleDir, 'json'));
|
||||
gulp.watch(`${src}/**/*.ts`, tsCompiler(exampleDir, exampleConfig));
|
||||
gulp.watch(`${src}/**/*.less`, lessCompiler(exampleDir));
|
||||
gulp.watch(`${src}/**/*.wxml`, copier(exampleDir, 'wxml'));
|
||||
gulp.watch(`${src}/**/*.wxs`, copier(exampleDir, 'wxs'));
|
||||
gulp.watch(`${src}/**/*.json`, copier(exampleDir, 'json'));
|
||||
}
|
||||
)
|
||||
)
|
||||
};
|
||||
);
|
||||
|
||||
module.exports = tasks;
|
||||
|
@ -7,4 +7,6 @@ const gulpConfig = path.resolve(__dirname, './compiler.js');
|
||||
|
||||
serve({}, { config });
|
||||
|
||||
exec(`npx gulp -f ${gulpConfig} buildExample`);
|
||||
const p = exec(`npx gulp -f ${gulpConfig} buildExample --color`);
|
||||
p.stdout.on('data', stdout => console.info(stdout));
|
||||
p.stderr.on('data', stderr => console.info(stderr));
|
||||
|
Loading…
x
Reference in New Issue
Block a user