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,70 +18,78 @@ const libDir = path.resolve(__dirname, '../lib');
|
|||||||
const esDir = path.resolve(__dirname, '../dist');
|
const esDir = path.resolve(__dirname, '../dist');
|
||||||
const exampleDir = path.resolve(__dirname, '../example/dist');
|
const exampleDir = path.resolve(__dirname, '../example/dist');
|
||||||
|
|
||||||
const compileLess = dist => () =>
|
const lessCompiler = dist =>
|
||||||
gulp
|
function compileLess() {
|
||||||
.src(`${src}/**/*.less`)
|
return gulp
|
||||||
.pipe(less())
|
.src(`${src}/**/*.less`)
|
||||||
.pipe(postcss())
|
.pipe(less())
|
||||||
.pipe(
|
.pipe(postcss())
|
||||||
insert.transform((contents, file) => {
|
.pipe(
|
||||||
if (!file.path.includes('packages' + path.sep + 'common')) {
|
insert.transform((contents, file) => {
|
||||||
contents = `@import '../common/index.wxss';${contents}`;
|
if (!file.path.includes('packages' + path.sep + 'common')) {
|
||||||
}
|
contents = `@import '../common/index.wxss';${contents}`;
|
||||||
return contents;
|
}
|
||||||
})
|
return contents;
|
||||||
)
|
})
|
||||||
.pipe(
|
)
|
||||||
rename(path => {
|
.pipe(rename({ extname: '.wxss' }))
|
||||||
path.extname = '.wxss';
|
.pipe(gulp.dest(dist));
|
||||||
})
|
};
|
||||||
)
|
|
||||||
.pipe(gulp.dest(dist));
|
|
||||||
|
|
||||||
const compileTs = (config, dest) => async () => {
|
const tsCompiler = (dist, config) =>
|
||||||
await exec(`npx tsc -p ${config}`);
|
async function compileTs() {
|
||||||
await exec(`npx tscpaths -p ${config} -s ../packages -o ../${dest}`);
|
await exec(`npx tsc -p ${config}`);
|
||||||
};
|
await exec(`npx tscpaths -p ${config} -s ../packages -o ${dist}`);
|
||||||
|
};
|
||||||
|
|
||||||
const copy = (dist, ext) => () =>
|
const copier = (dist, ext) =>
|
||||||
gulp.src(`${src}/**/*.${ext}`).pipe(gulp.dest(dist));
|
function copy() {
|
||||||
|
return gulp.src(`${src}/**/*.${ext}`).pipe(gulp.dest(dist));
|
||||||
|
};
|
||||||
|
|
||||||
const copyStatic = dist =>
|
const staticCopier = dist =>
|
||||||
gulp.parallel(copy(dist, 'wxml'), copy(dist, 'wxs'), copy(dist, 'json'));
|
gulp.parallel(
|
||||||
|
copier(dist, 'wxml'),
|
||||||
|
copier(dist, 'wxs'),
|
||||||
|
copier(dist, 'json')
|
||||||
|
);
|
||||||
|
|
||||||
const clean = path => () => exec(`npx rimraf ${path}`);
|
const cleaner = path =>
|
||||||
|
function clean() {
|
||||||
|
return exec(`npx rimraf ${path}`);
|
||||||
|
};
|
||||||
|
|
||||||
module.exports = {
|
const tasks = [
|
||||||
buildEs: gulp.series(
|
['buildEs', esDir, esConfig],
|
||||||
clean(esDir),
|
['buildLib', libDir, libConfig]
|
||||||
|
].reduce((prev, [name, ...args]) => {
|
||||||
|
prev[name] = gulp.series(
|
||||||
|
cleaner(...args),
|
||||||
gulp.parallel(
|
gulp.parallel(
|
||||||
compileTs(esConfig, esDir),
|
tsCompiler(...args),
|
||||||
compileLess(esDir),
|
lessCompiler(...args),
|
||||||
copyStatic(esDir)
|
staticCopier(...args)
|
||||||
)
|
|
||||||
),
|
|
||||||
buildLib: gulp.series(
|
|
||||||
clean(libDir),
|
|
||||||
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`)),
|
|
||||||
() => {
|
|
||||||
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'));
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
|
);
|
||||||
|
return prev;
|
||||||
|
}, {});
|
||||||
|
|
||||||
|
tasks.buildExample = gulp.series(
|
||||||
|
cleaner(exampleDir),
|
||||||
|
gulp.parallel(
|
||||||
|
tsCompiler(exampleDir, exampleConfig),
|
||||||
|
lessCompiler(exampleDir),
|
||||||
|
staticCopier(exampleDir),
|
||||||
|
() =>
|
||||||
|
gulp.src(`${icons}/**/*`).pipe(gulp.dest(`${exampleDir}/@vant/icons`)),
|
||||||
|
() => {
|
||||||
|
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 });
|
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