mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
[build] remove gulp
This commit is contained in:
parent
ddca7eeca8
commit
9fc2bed48e
@ -1,32 +1,61 @@
|
|||||||
const fs = require('fs-extra');
|
const fs = require('fs-extra');
|
||||||
const glob = require('fast-glob');
|
const glob = require('fast-glob');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const gulp = require('gulp');
|
const less = require('less');
|
||||||
const less = require('gulp-less');
|
const csso = require('csso');
|
||||||
const csso = require('gulp-csso');
|
const postcss = require('postcss');
|
||||||
const postcss = require('gulp-postcss');
|
const postcssrc = require('postcss-load-config');
|
||||||
|
|
||||||
|
async function compileLess(lessCodes, paths) {
|
||||||
|
const outputs = await Promise.all(
|
||||||
|
lessCodes.map((source, index) =>
|
||||||
|
less.render(source, {
|
||||||
|
paths: [path.resolve(__dirname, 'node_modules')],
|
||||||
|
filename: paths[index]
|
||||||
|
})
|
||||||
|
)
|
||||||
|
);
|
||||||
|
return outputs.map(item => item.css);
|
||||||
|
}
|
||||||
|
|
||||||
|
async function compilePostcss(cssCodes, paths) {
|
||||||
|
const postcssConfig = await postcssrc();
|
||||||
|
const outputs = await Promise.all(
|
||||||
|
cssCodes.map((css, index) =>
|
||||||
|
postcss(postcssConfig.plugins).process(css, { from: paths[index] })
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return outputs.map(item => item.css);
|
||||||
|
}
|
||||||
|
|
||||||
|
async function compileCsso(cssCodes) {
|
||||||
|
return cssCodes.map(css => csso.minify(css).css);
|
||||||
|
}
|
||||||
|
|
||||||
|
async function dest(output, paths) {
|
||||||
|
await Promise.all(
|
||||||
|
output.map((css, index) => fs.writeFile(paths[index].replace('.less', '.css'), css))
|
||||||
|
);
|
||||||
|
|
||||||
|
// icon.less should be replaced by compiled file
|
||||||
|
const iconCss = await glob(['./es/icon/*.css', './lib/icon/*.css'], { absolute: true });
|
||||||
|
iconCss.forEach(file => {
|
||||||
|
fs.copyFileSync(file, file.replace('.css', '.less'));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// compile component css
|
// compile component css
|
||||||
gulp.task('compile', () => (
|
async function compile() {
|
||||||
gulp
|
let codes;
|
||||||
.src(['../es/**/*.less', '../lib/**/*.less'])
|
const paths = await glob(['./es/**/*.less', './lib/**/*.less'], { absolute: true });
|
||||||
.pipe(less({
|
|
||||||
paths: [path.resolve(__dirname, 'node_modules')]
|
|
||||||
}))
|
|
||||||
.pipe(postcss())
|
|
||||||
.pipe(csso())
|
|
||||||
.pipe(gulp.dest(file => file.base.replace('.less', '.css')))
|
|
||||||
));
|
|
||||||
|
|
||||||
// icon.less should be replaced by compiled file
|
codes = await Promise.all(paths.map(path => fs.readFile(path, 'utf-8')));
|
||||||
gulp.task('default', ['compile'], () => (
|
codes = await compileLess(codes, paths);
|
||||||
glob([
|
codes = await compilePostcss(codes, paths);
|
||||||
'../es/icon/*.css',
|
codes = await compileCsso(codes);
|
||||||
'../lib/icon/*.css'
|
|
||||||
]).then(files => {
|
await dest(codes, paths);
|
||||||
files.forEach(file => {
|
}
|
||||||
file = path.join(__dirname, file);
|
|
||||||
fs.copyFileSync(file, file.replace('.css', '.less'));
|
compile();
|
||||||
});
|
|
||||||
})
|
|
||||||
));
|
|
||||||
|
@ -25,10 +25,7 @@ module.exports = {
|
|||||||
clientLogLevel: 'warning'
|
clientLogLevel: 'warning'
|
||||||
},
|
},
|
||||||
resolve: {
|
resolve: {
|
||||||
extensions: ['.js', '.ts', '.tsx', '.vue', '.css'],
|
extensions: ['.js', '.ts', '.tsx', '.vue', '.css']
|
||||||
alias: {
|
|
||||||
packages: path.join(__dirname, '../packages')
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
module: {
|
module: {
|
||||||
rules: [
|
rules: [
|
||||||
|
16
package.json
16
package.json
@ -20,11 +20,11 @@
|
|||||||
"build:entry": "node build/build-entry.js",
|
"build:entry": "node build/build-entry.js",
|
||||||
"build:components": "node build/build-components.js --color",
|
"build:components": "node build/build-components.js --color",
|
||||||
"build:vant": "cross-env NODE_ENV=production webpack --color --config build/webpack.build.js && cross-env NODE_ENV=production webpack -p --color --config build/webpack.build.js",
|
"build:vant": "cross-env NODE_ENV=production webpack --color --config build/webpack.build.js && cross-env NODE_ENV=production webpack -p --color --config build/webpack.build.js",
|
||||||
"build:style": "gulp --gulpfile ./build/build-style.js",
|
"build:style": "node build/build-style.js",
|
||||||
"build:style-entry": "node build/build-style-entry.js",
|
"build:style-entry": "node build/build-style-entry.js",
|
||||||
"build:changelog": "vant-doc changelog ./changelog.generated.md",
|
"build:changelog": "vant-doc changelog ./changelog.generated.md",
|
||||||
"build:lib": "node build/build-lib.js",
|
"build:lib": "node build/build-lib.js",
|
||||||
"build:site": "rimraf docs/dist && cross-env NODE_ENV=production webpack --config build/webpack.doc.js && gh-pages -d docs/dist",
|
"build:site": "rm -rf docs/dist && cross-env NODE_ENV=production webpack --config build/webpack.doc.js && gh-pages -d docs/dist",
|
||||||
"test": "jest",
|
"test": "jest",
|
||||||
"test:watch": "jest --watch",
|
"test:watch": "jest --watch",
|
||||||
"test:clear-cache": "jest --clearCache",
|
"test:clear-cache": "jest --clearCache",
|
||||||
@ -61,8 +61,7 @@
|
|||||||
"@babel/runtime": "^7.4.4",
|
"@babel/runtime": "^7.4.4",
|
||||||
"@vant/icons": "1.1.7",
|
"@vant/icons": "1.1.7",
|
||||||
"@vue/babel-helper-vue-jsx-merge-props": "^1.0.0-beta.3",
|
"@vue/babel-helper-vue-jsx-merge-props": "^1.0.0-beta.3",
|
||||||
"vue-lazyload": "1.2.3",
|
"vue-lazyload": "1.2.3"
|
||||||
"webpack-dev-server": "^3.3.1"
|
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"vue": ">= 2.5.0"
|
"vue": ">= 2.5.0"
|
||||||
@ -89,14 +88,11 @@
|
|||||||
"codecov": "^3.3.0",
|
"codecov": "^3.3.0",
|
||||||
"cross-env": "^5.2.0",
|
"cross-env": "^5.2.0",
|
||||||
"css-loader": "^2.1.1",
|
"css-loader": "^2.1.1",
|
||||||
|
"csso": "^3.5.1",
|
||||||
"dependency-tree": "^7.0.2",
|
"dependency-tree": "^7.0.2",
|
||||||
"eslint": "^5.16.0",
|
"eslint": "^5.16.0",
|
||||||
"fast-glob": "^2.2.4",
|
"fast-glob": "^2.2.4",
|
||||||
"gh-pages": "^2.0.1",
|
"gh-pages": "^2.0.1",
|
||||||
"gulp": "3.9.1",
|
|
||||||
"gulp-csso": "^3.0.1",
|
|
||||||
"gulp-less": "^4.0.1",
|
|
||||||
"gulp-postcss": "^8.0.0",
|
|
||||||
"html-webpack-plugin": "3.2.0",
|
"html-webpack-plugin": "3.2.0",
|
||||||
"husky": "^2.2.0",
|
"husky": "^2.2.0",
|
||||||
"jest": "^24.8.0",
|
"jest": "^24.8.0",
|
||||||
@ -108,7 +104,6 @@
|
|||||||
"postcss": "^7.0.16",
|
"postcss": "^7.0.16",
|
||||||
"postcss-loader": "^3.0.0",
|
"postcss-loader": "^3.0.0",
|
||||||
"progress-bar-webpack-plugin": "^1.12.1",
|
"progress-bar-webpack-plugin": "^1.12.1",
|
||||||
"rimraf": "^2.5.4",
|
|
||||||
"shelljs": "^0.8.3",
|
"shelljs": "^0.8.3",
|
||||||
"signale": "^1.4.0",
|
"signale": "^1.4.0",
|
||||||
"style-loader": "^0.23.1",
|
"style-loader": "^0.23.1",
|
||||||
@ -126,7 +121,8 @@
|
|||||||
"vue-template-compiler": "2.6.10",
|
"vue-template-compiler": "2.6.10",
|
||||||
"vue-template-es2015-compiler": "^1.9.1",
|
"vue-template-es2015-compiler": "^1.9.1",
|
||||||
"webpack": "^4.30.0",
|
"webpack": "^4.30.0",
|
||||||
"webpack-cli": "^3.3.2"
|
"webpack-cli": "^3.3.2",
|
||||||
|
"webpack-dev-server": "^3.3.1"
|
||||||
},
|
},
|
||||||
"vetur": {
|
"vetur": {
|
||||||
"tags": "vetur/tags.json",
|
"tags": "vetur/tags.json",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user