[build]: upgrade dependence & use cssnano instead of clean-css

This commit is contained in:
rex 2019-03-23 00:06:26 +08:00 committed by GitHub
parent ca4d460489
commit bb30557966
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 3768 additions and 2746 deletions

View File

@ -4,25 +4,22 @@ const less = require('gulp-less');
const ts = require('gulp-typescript');
const insert = require('gulp-insert');
const rename = require('gulp-rename');
const cssmin = require('gulp-clean-css');
const postcss = require('gulp-postcss');
const tsProject = ts.createProject(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 ext = ['ts', 'less', 'json', 'wxml', 'wxs'];
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', () => {
return gulp
.src([src + '/**/*.less'])
function compileLess() {
gulp
.src(`${src}/**/*.less`)
.pipe(less())
.pipe(postcss())
.pipe(cssmin())
.pipe(
insert.transform((contents, file) => {
if (!file.path.includes('packages' + path.sep + 'common')) {
@ -37,23 +34,26 @@ gulp.task('compile-less', () => {
})
)
.pipe(gulp.dest(dist));
});
}
gulp.task('compile-ts', () =>
function compileTs() {
tsProject
.src()
.pipe(tsProject())
.on('error', () => {})
.pipe(gulp.dest(dist))
);
gulp.task('compile-wxs', () => copy('wxs'));
gulp.task('compile-json', () => copy('json'));
gulp.task('compile-wxml', () => copy('wxml'));
gulp.task('build', ext.map(ext => 'compile-' + ext));
gulp.start('build');
.pipe(gulp.dest(dist));
}
const compileWxml = () => copy('wxml');
const compileJson = () => copy('json');
const compileWxs = () => copy('wxs');
if (!isProduction) {
ext.forEach(ext => {
gulp.watch(src + '/**/*.' + ext, ['compile-' + ext]);
});
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)();

View File

@ -31,12 +31,12 @@
"babel-loader": "8.0.5",
"cross-env": "^5.1.4",
"css-loader": "^2.1.0",
"cssnano": "^4.1.10",
"eslint": "^5.11.1",
"eslint-plugin-vue-libs": "^3.0.0",
"fast-vue-md-loader": "^1.0.3",
"gh-pages": "^2.0.1",
"gulp": "^3.9.1",
"gulp-clean-css": "^4.0.0",
"gulp": "^4.0.0",
"gulp-insert": "^0.5.0",
"gulp-less": "^4.0.1",
"gulp-postcss": "^8.0.0",
@ -55,7 +55,6 @@
"vue-router": "^3.0.2",
"vue-template-compiler": "2.5.21",
"webpack": "^4.28.3",
"webpack-cli": "^3.2.0",
"webpack-serve": "^2.0.3"
}
}

View File

@ -1,5 +1,8 @@
module.exports = {
plugins: {
'autoprefixer': {}
autoprefixer: {},
cssnano: {
preset: 'default'
}
}
};

6466
yarn.lock

File diff suppressed because it is too large Load Diff