修复 windows 平台 npm run dist 任务异常的问题 (#301)

This commit is contained in:
秦天翔 2017-11-09 23:56:52 -06:00 committed by neverland
parent 874dd0cefa
commit fbcb691699
3 changed files with 12 additions and 5 deletions

View File

@ -7,6 +7,8 @@ const path = require('path');
const components = require('./get-components')();
const dependencyTree = require('dependency-tree');
const SEP = path.sep;
components.forEach(componentName => {
const libDir = path.resolve(__dirname, '../../lib');
const content = analyzeDependencies(componentName, libDir).map(component => `require('../../vant-css/${component}.css');`);
@ -19,7 +21,7 @@ function analyzeDependencies(componentName, libDir) {
search(dependencyTree({
directory: libDir,
filename: path.resolve(libDir, componentName, 'index.js'),
filter: path => path.indexOf('vant/lib/') !== -1
filter: path => path.indexOf(`vant${SEP}lib${SEP}`) !== -1
}), checkList);
return checkList.filter(component => checkComponentHasStyle(component));
}
@ -27,7 +29,7 @@ function analyzeDependencies(componentName, libDir) {
function search(tree, checkList) {
tree && Object.keys(tree).forEach(key => {
search(tree[key], checkList);
const component = key.split('/vant/lib/')[1].replace('/index.js', '').replace('mixins/', '');
const component = key.split(`${SEP}vant${SEP}lib${SEP}`)[1].replace(`${SEP}index.js`, '').replace(`mixins${SEP}`, '');
if (checkList.indexOf(component) === -1) {
checkList.push(component);
}

View File

@ -15,9 +15,9 @@
"dev": "npm run build:file && webpack-dev-server --inline --config build/webpack.config.dev.js --content-base ./",
"build:file": "node build/bin/build-entry.js",
"build:components": "node build/bin/build-components.js --color",
"build:vant-css": "gulp build --gulpfile packages/vant-css/gulpfile.js --color && mkdir lib/vant-css && cp -R packages/vant-css/lib/ lib/vant-css",
"build:vant-css": "gulp build --gulpfile packages/vant-css/gulpfile.js --color",
"build:vant": "cross-env NODE_ENV=production webpack --progress --hide-modules --color --config build/webpack.build.js && cross-env NODE_ENV=production webpack -p --progress --hide-modules --color --config build/webpack.build.js",
"build:style-entry": "VUE_ENV=server node build/bin/build-style-entry.js",
"build:style-entry": "cross-env VUE_ENV=server node build/bin/build-style-entry.js",
"build:changelog": "sh build/bin/build-changelog.sh",
"deploy": "npm run deploy:docs && npm run deploy:cdn && gh-pages -d docs/dist --remote youzan && rimraf docs/dist",
"deploy:cdn": "superman cdn /zanui/vant docs/dist/*.js docs/dist/*.css && superman cdn /zanui/vant/async_en-US docs/dist/async_en-US/*.js && superman cdn /zanui/vant/async_zh-CN docs/dist/async_zh-CN/*.js",
@ -75,7 +75,10 @@
"friendly-errors-webpack-plugin": "^1.6.1",
"gh-pages": "^1.0.0",
"gulp": "^3.9.1",
"gulp-clean-css": "^3.9.0",
"gulp-cssmin": "^0.2.0",
"gulp-iconfont": "^9.0.2",
"gulp-iconfont-css": "^2.1.0",
"gulp-postcss": "^7.0.0",
"gulp-util": "^3.0.8",
"highlight.js": "^9.12.0",
@ -93,6 +96,7 @@
"karma-webpack": "^2.0.4",
"markdown-it": "^8.4.0",
"markdown-it-container": "^2.0.0",
"md5-file": "^3.2.3",
"mocha": "^3.4.2",
"postcss": "^6.0.14",
"postcss-calc": "^6.0.0",

View File

@ -35,7 +35,8 @@ gulp.task('compile', () => {
.src('./src/*.css')
.pipe(postcss())
.pipe(cssmin())
.pipe(gulp.dest('./lib'));
.pipe(gulp.dest('./lib'))
.pipe(gulp.dest('../../lib/vant-css/'));
});
gulp.task('icon-font-ttf', () => {