mirror of
https://gitee.com/vant-contrib/vant-weapp.git
synced 2025-04-06 03:58:05 +08:00
parent
17c84a5088
commit
cded2c8a4f
@ -6,16 +6,21 @@ const insert = require('gulp-insert');
|
||||
const rename = require('gulp-rename');
|
||||
const postcss = require('gulp-postcss');
|
||||
|
||||
const tsProject = ts.createProject(path.resolve(__dirname, '../tsconfig.json'));
|
||||
const tsConfig = path.resolve(__dirname, '../tsconfig.json');
|
||||
const isProduction = process.env.NODE_ENV === 'production';
|
||||
const src = path.join(__dirname, '../packages');
|
||||
const dist = path.join(__dirname, isProduction ? '../dist' : '../example/dist');
|
||||
const libDir = path.resolve(__dirname, '../lib');
|
||||
const esDir = path.resolve(__dirname, '../dist');
|
||||
const exampleDir = path.resolve(__dirname, '../example/dist');
|
||||
|
||||
function copy(ext) {
|
||||
return gulp.src(`${src}/**/*.${ext}`).pipe(gulp.dest(dist));
|
||||
}
|
||||
const libConfig = {
|
||||
target: 'es5',
|
||||
lib: ['es2015', 'es2017', 'dom'],
|
||||
module: 'commonjs',
|
||||
declaration: false
|
||||
};
|
||||
|
||||
function compileLess() {
|
||||
const compileLess = dist => () =>
|
||||
gulp
|
||||
.src(`${src}/**/*.less`)
|
||||
.pipe(less())
|
||||
@ -34,26 +39,36 @@ function compileLess() {
|
||||
})
|
||||
)
|
||||
.pipe(gulp.dest(dist));
|
||||
}
|
||||
|
||||
function compileTs() {
|
||||
tsProject
|
||||
const compileTs = (dist, config) => () => {
|
||||
const tsProject = ts.createProject(tsConfig, config);
|
||||
return tsProject
|
||||
.src()
|
||||
.pipe(tsProject())
|
||||
.on('error', () => {})
|
||||
.pipe(gulp.dest(dist));
|
||||
};
|
||||
|
||||
const copy = (dist, ext) => () =>
|
||||
gulp.src(`${src}/**/*.${ext}`).pipe(gulp.dest(dist));
|
||||
|
||||
const compile = (dist, config) =>
|
||||
gulp.parallel(
|
||||
compileTs(dist, config),
|
||||
compileLess(dist),
|
||||
copy(dist, 'wxml'),
|
||||
copy(dist, 'wxs'),
|
||||
copy(dist, 'json')
|
||||
);
|
||||
|
||||
if (isProduction) {
|
||||
gulp.series(compile(esDir), compile(libDir, libConfig))();
|
||||
} else {
|
||||
compile(exampleDir)();
|
||||
|
||||
gulp.watch(`${src}/**/*.ts`, compileTs(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'));
|
||||
}
|
||||
|
||||
const compileWxml = () => copy('wxml');
|
||||
const compileJson = () => copy('json');
|
||||
const compileWxs = () => copy('wxs');
|
||||
|
||||
if (!isProduction) {
|
||||
gulp.watch(`${src}/**/*.ts`, compileTs);
|
||||
gulp.watch(`${src}/**/*.less`, compileLess);
|
||||
gulp.watch(`${src}/**/*.wxml`, compileWxml);
|
||||
gulp.watch(`${src}/**/*.wxs`, compileWxs);
|
||||
gulp.watch(`${src}/**/*.json`, compileJson);
|
||||
}
|
||||
|
||||
gulp.parallel(compileTs, compileLess, compileWxml, compileJson, compileWxs)();
|
||||
|
@ -9,12 +9,13 @@
|
||||
"dev": "node build/dev.js",
|
||||
"lint": "eslint ./packages --ext .js",
|
||||
"release": "sh build/release.sh",
|
||||
"build:lib": "yarn && rm -rf dist && NODE_ENV=production node build/compiler.js",
|
||||
"build:lib": "yarn && rm -rf dist && rm -rf lib && NODE_ENV=production node build/compiler.js",
|
||||
"build:site": "rm -rf docs/dist && cross-env NODE_ENV=production webpack --config build/webpack.doc.prd.js && gh-pages -d docs/dist",
|
||||
"build:changelog": "vant-doc changelog --tag v0.5.0 changelog.generated.md"
|
||||
},
|
||||
"files": [
|
||||
"dist"
|
||||
"dist",
|
||||
"lib"
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
Loading…
x
Reference in New Issue
Block a user