mirror of
https://gitee.com/vant-contrib/vant-weapp.git
synced 2025-04-05 02:12:43 +08:00
[build]: upgrade dependence & use cssnano instead of clean-css
This commit is contained in:
parent
ca4d460489
commit
bb30557966
@ -4,25 +4,22 @@ const less = require('gulp-less');
|
|||||||
const ts = require('gulp-typescript');
|
const ts = require('gulp-typescript');
|
||||||
const insert = require('gulp-insert');
|
const insert = require('gulp-insert');
|
||||||
const rename = require('gulp-rename');
|
const rename = require('gulp-rename');
|
||||||
const cssmin = require('gulp-clean-css');
|
|
||||||
const postcss = require('gulp-postcss');
|
const postcss = require('gulp-postcss');
|
||||||
|
|
||||||
const tsProject = ts.createProject(path.resolve(__dirname, '../tsconfig.json'));
|
const tsProject = ts.createProject(path.resolve(__dirname, '../tsconfig.json'));
|
||||||
const isProduction = process.env.NODE_ENV === 'production';
|
const isProduction = process.env.NODE_ENV === 'production';
|
||||||
const src = path.join(__dirname, '../packages');
|
const src = path.join(__dirname, '../packages');
|
||||||
const dist = path.join(__dirname, isProduction ? '../dist' : '../example/dist');
|
const dist = path.join(__dirname, isProduction ? '../dist' : '../example/dist');
|
||||||
const ext = ['ts', 'less', 'json', 'wxml', 'wxs'];
|
|
||||||
|
|
||||||
function copy(ext) {
|
function copy(ext) {
|
||||||
return gulp.src([src + '/**/*.' + ext]).pipe(gulp.dest(dist));
|
return gulp.src(`${src}/**/*.${ext}`).pipe(gulp.dest(dist));
|
||||||
}
|
}
|
||||||
|
|
||||||
gulp.task('compile-less', () => {
|
function compileLess() {
|
||||||
return gulp
|
gulp
|
||||||
.src([src + '/**/*.less'])
|
.src(`${src}/**/*.less`)
|
||||||
.pipe(less())
|
.pipe(less())
|
||||||
.pipe(postcss())
|
.pipe(postcss())
|
||||||
.pipe(cssmin())
|
|
||||||
.pipe(
|
.pipe(
|
||||||
insert.transform((contents, file) => {
|
insert.transform((contents, file) => {
|
||||||
if (!file.path.includes('packages' + path.sep + 'common')) {
|
if (!file.path.includes('packages' + path.sep + 'common')) {
|
||||||
@ -37,23 +34,26 @@ gulp.task('compile-less', () => {
|
|||||||
})
|
})
|
||||||
)
|
)
|
||||||
.pipe(gulp.dest(dist));
|
.pipe(gulp.dest(dist));
|
||||||
});
|
}
|
||||||
|
|
||||||
gulp.task('compile-ts', () =>
|
function compileTs() {
|
||||||
tsProject
|
tsProject
|
||||||
.src()
|
.src()
|
||||||
.pipe(tsProject())
|
.pipe(tsProject())
|
||||||
.on('error', () => {})
|
.on('error', () => {})
|
||||||
.pipe(gulp.dest(dist))
|
.pipe(gulp.dest(dist));
|
||||||
);
|
}
|
||||||
gulp.task('compile-wxs', () => copy('wxs'));
|
|
||||||
gulp.task('compile-json', () => copy('json'));
|
const compileWxml = () => copy('wxml');
|
||||||
gulp.task('compile-wxml', () => copy('wxml'));
|
const compileJson = () => copy('json');
|
||||||
gulp.task('build', ext.map(ext => 'compile-' + ext));
|
const compileWxs = () => copy('wxs');
|
||||||
gulp.start('build');
|
|
||||||
|
|
||||||
if (!isProduction) {
|
if (!isProduction) {
|
||||||
ext.forEach(ext => {
|
gulp.watch('src/**/*.ts', compileTs);
|
||||||
gulp.watch(src + '/**/*.' + ext, ['compile-' + ext]);
|
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)();
|
||||||
|
@ -31,12 +31,12 @@
|
|||||||
"babel-loader": "8.0.5",
|
"babel-loader": "8.0.5",
|
||||||
"cross-env": "^5.1.4",
|
"cross-env": "^5.1.4",
|
||||||
"css-loader": "^2.1.0",
|
"css-loader": "^2.1.0",
|
||||||
|
"cssnano": "^4.1.10",
|
||||||
"eslint": "^5.11.1",
|
"eslint": "^5.11.1",
|
||||||
"eslint-plugin-vue-libs": "^3.0.0",
|
"eslint-plugin-vue-libs": "^3.0.0",
|
||||||
"fast-vue-md-loader": "^1.0.3",
|
"fast-vue-md-loader": "^1.0.3",
|
||||||
"gh-pages": "^2.0.1",
|
"gh-pages": "^2.0.1",
|
||||||
"gulp": "^3.9.1",
|
"gulp": "^4.0.0",
|
||||||
"gulp-clean-css": "^4.0.0",
|
|
||||||
"gulp-insert": "^0.5.0",
|
"gulp-insert": "^0.5.0",
|
||||||
"gulp-less": "^4.0.1",
|
"gulp-less": "^4.0.1",
|
||||||
"gulp-postcss": "^8.0.0",
|
"gulp-postcss": "^8.0.0",
|
||||||
@ -55,7 +55,6 @@
|
|||||||
"vue-router": "^3.0.2",
|
"vue-router": "^3.0.2",
|
||||||
"vue-template-compiler": "2.5.21",
|
"vue-template-compiler": "2.5.21",
|
||||||
"webpack": "^4.28.3",
|
"webpack": "^4.28.3",
|
||||||
"webpack-cli": "^3.2.0",
|
|
||||||
"webpack-serve": "^2.0.3"
|
"webpack-serve": "^2.0.3"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
plugins: {
|
plugins: {
|
||||||
'autoprefixer': {}
|
autoprefixer: {},
|
||||||
|
cssnano: {
|
||||||
|
preset: 'default'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user