From 1b91cd587632bcf1d3b12f354d8610032f94599e Mon Sep 17 00:00:00 2001 From: neverland Date: Sun, 15 Nov 2020 12:09:09 +0800 Subject: [PATCH 1/5] feat(cli): postcss plugins can be array (#7560) --- packages/vant-cli/src/common/index.ts | 15 +------ .../vant-cli/src/config/postcss.config.ts | 44 ++++++++++++------- 2 files changed, 28 insertions(+), 31 deletions(-) diff --git a/packages/vant-cli/src/common/index.ts b/packages/vant-cli/src/common/index.ts index 8cb091a93..56e09da82 100644 --- a/packages/vant-cli/src/common/index.ts +++ b/packages/vant-cli/src/common/index.ts @@ -7,12 +7,7 @@ import { outputFileSync, } from 'fs-extra'; import merge from 'webpack-merge'; -import { - SRC_DIR, - getVantConfig, - ROOT_WEBPACK_CONFIG_FILE, - ROOT_POSTCSS_CONFIG_FILE, -} from './constant'; +import { SRC_DIR, getVantConfig, ROOT_WEBPACK_CONFIG_FILE } from './constant'; import { WebpackConfig } from './types'; export const EXT_REGEXP = /\.\w+$/; @@ -117,14 +112,6 @@ export function getWebpackConfig(defaultConfig: WebpackConfig): object { return defaultConfig; } -export function getPostcssConfig(): object { - if (existsSync(ROOT_POSTCSS_CONFIG_FILE)) { - return require(ROOT_POSTCSS_CONFIG_FILE); - } - - return {}; -} - export type ModuleEnv = 'esmodule' | 'commonjs'; export type NodeEnv = 'production' | 'development' | 'test'; export type BuildTarget = 'site' | 'package'; diff --git a/packages/vant-cli/src/config/postcss.config.ts b/packages/vant-cli/src/config/postcss.config.ts index 51fbb6c5e..e171a429d 100644 --- a/packages/vant-cli/src/config/postcss.config.ts +++ b/packages/vant-cli/src/config/postcss.config.ts @@ -1,26 +1,36 @@ -import { getPostcssConfig } from '../common'; +import { existsSync } from 'fs-extra'; +import { ROOT_POSTCSS_CONFIG_FILE } from '../common/constant'; -type PostcssConfig = object & { - plugins?: object; +type PostcssConfig = { + plugins?: Record | unknown[]; }; -function mergePostcssConfig(config1: PostcssConfig, config2: PostcssConfig) { - const plugins = { - ...config1.plugins, - ...config2.plugins, - }; +export function getRootPostcssConfig(): PostcssConfig { + if (existsSync(ROOT_POSTCSS_CONFIG_FILE)) { + return require(ROOT_POSTCSS_CONFIG_FILE); + } + return { plugins: [] }; +} + +function getPostcssPlugins(rootConfig: PostcssConfig) { + const plugins = rootConfig.plugins || []; + + if (Array.isArray(plugins)) { + return [require('autoprefixer'), ...plugins]; + } return { - ...config1, - ...config2, - plugins, + autoprefixer: {}, + ...plugins, }; } -const DEFAULT_CONFIG = { - plugins: { - autoprefixer: {}, - }, -}; +function resolvePostcssConfig() { + const rootConfig = getRootPostcssConfig(); + return { + ...rootConfig, + plugins: getPostcssPlugins(rootConfig), + }; +} -module.exports = mergePostcssConfig(DEFAULT_CONFIG, getPostcssConfig()); +module.exports = resolvePostcssConfig(); From a4a3b37fb1d0524eaa8d6a060582403bb182b73b Mon Sep 17 00:00:00 2001 From: chenjiahan Date: Sun, 15 Nov 2020 12:10:27 +0800 Subject: [PATCH 2/5] chore: release @vant/cli@2.6.2 --- packages/vant-cli/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/vant-cli/package.json b/packages/vant-cli/package.json index e58f65ee7..e57dd8bdb 100644 --- a/packages/vant-cli/package.json +++ b/packages/vant-cli/package.json @@ -1,6 +1,6 @@ { "name": "@vant/cli", - "version": "2.6.1", + "version": "2.6.2", "description": "", "main": "lib/index.js", "typings": "lib/index.d.ts", From 656909613bdcd70c544a29eeadf021aadd669aec Mon Sep 17 00:00:00 2001 From: chenjiahan Date: Sun, 15 Nov 2020 12:14:01 +0800 Subject: [PATCH 3/5] docs(cli): changelog 2.6.2 --- package.json | 6 +++--- packages/vant-cli/changelog.md | 6 ++++++ yarn.lock | 34 +++++++++++++++++----------------- 3 files changed, 26 insertions(+), 20 deletions(-) diff --git a/package.json b/package.json index c382dddf2..e942113aa 100644 --- a/package.json +++ b/package.json @@ -62,10 +62,10 @@ "vue": ">= 2.5.22" }, "devDependencies": { - "@vant/cli": "^2.6.0", + "@vant/cli": "^2.6.2", "prettier": "^2.0.4", - "vue": "^2.6.11", - "vue-template-compiler": "^2.6.11" + "vue": "^2.6.12", + "vue-template-compiler": "^2.6.12" }, "sideEffects": [ "es/**/style/*", diff --git a/packages/vant-cli/changelog.md b/packages/vant-cli/changelog.md index 0ae0b378c..88fcb4420 100644 --- a/packages/vant-cli/changelog.md +++ b/packages/vant-cli/changelog.md @@ -1,5 +1,11 @@ # 更新日志 +## v2.6.2 + +`2020-11-15` + +- 支持自定义 postcss 配置时传入数组格式的 plugins + ### v2.6.1 `2020-10-09` diff --git a/yarn.lock b/yarn.lock index 4a67dfa58..dfca40127 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1995,10 +1995,10 @@ semver "^6.3.0" tsutils "^3.17.1" -"@vant/cli@^2.6.0": - version "2.6.0" - resolved "https://registry.npm.taobao.org/@vant/cli/download/@vant/cli-2.6.0.tgz?cache=0&sync_timestamp=1601208618517&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2F%40vant%2Fcli%2Fdownload%2F%40vant%2Fcli-2.6.0.tgz#e40c195ee303747154d5d2cfca66560dba08d6a8" - integrity sha1-5AwZXuMDdHFU1dLPymZWDboI1qg= +"@vant/cli@^2.6.2": + version "2.6.2" + resolved "https://registry.npm.taobao.org/@vant/cli/download/@vant/cli-2.6.2.tgz#90346d3916a1d3a448ef030bc699d8d28a31efe5" + integrity sha1-kDRtORah06RI7wMLxpnY0oox7+U= dependencies: "@babel/core" "^7.10.1" "@babel/plugin-syntax-jsx" "^7.10.1" @@ -2012,7 +2012,7 @@ "@types/webpack-dev-server" "^3.11.0" "@vant/eslint-config" "^2.2.2" "@vant/markdown-loader" "^2.3.0" - "@vant/markdown-vetur" "^2.0.1" + "@vant/markdown-vetur" "^2.0.2" "@vant/stylelint-config" "^1.3.0" "@vant/touch-emulator" "^1.2.0" "@vue/babel-preset-jsx" "^1.1.2" @@ -2094,10 +2094,10 @@ markdown-it-anchor "^5.2.5" transliteration "^2.1.7" -"@vant/markdown-vetur@^2.0.1": - version "2.0.1" - resolved "https://registry.yarnpkg.com/@vant/markdown-vetur/-/markdown-vetur-2.0.1.tgz#cb0c2d33b5e5606e1dc7f3e6531c18b39d6e57a3" - integrity sha512-OhNFTQhCBlK+qIxfyw9unqU77Kf7gd5EsTUXPqg23lALWwpJiVb0IKGwxnYTZ9i7JAzTAho7oIGt7GQ0hhyvow== +"@vant/markdown-vetur@^2.0.2": + version "2.0.2" + resolved "https://registry.npm.taobao.org/@vant/markdown-vetur/download/@vant/markdown-vetur-2.0.2.tgz#8e6be188952a2c4b0e1d626bf93f47f84ab0f22d" + integrity sha1-jmvhiJUqLEsOHWJr+T9H+Eqw8i0= dependencies: fast-glob "^3.2.2" fs-extra "^9.0.0" @@ -12250,10 +12250,10 @@ vue-style-loader@^4.1.0: hash-sum "^1.0.2" loader-utils "^1.0.2" -vue-template-compiler@^2.6.11: - version "2.6.11" - resolved "https://registry.yarnpkg.com/vue-template-compiler/-/vue-template-compiler-2.6.11.tgz#c04704ef8f498b153130018993e56309d4698080" - integrity sha512-KIq15bvQDrcCjpGjrAhx4mUlyyHfdmTaoNfeoATHLAiWB+MU3cx4lOzMwrnUh9cCxy0Lt1T11hAFY6TQgroUAA== +vue-template-compiler@^2.6.12: + version "2.6.12" + resolved "https://registry.npm.taobao.org/vue-template-compiler/download/vue-template-compiler-2.6.12.tgz?cache=0&sync_timestamp=1597929252539&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fvue-template-compiler%2Fdownload%2Fvue-template-compiler-2.6.12.tgz#947ed7196744c8a5285ebe1233fe960437fcc57e" + integrity sha1-lH7XGWdEyKUoXr4SM/6WBDf8xX4= dependencies: de-indent "^1.0.2" he "^1.1.0" @@ -12263,10 +12263,10 @@ vue-template-es2015-compiler@^1.9.0: resolved "https://registry.yarnpkg.com/vue-template-es2015-compiler/-/vue-template-es2015-compiler-1.9.1.tgz#1ee3bc9a16ecbf5118be334bb15f9c46f82f5825" integrity sha512-4gDntzrifFnCEvyoO8PqyJDmguXgVPxKiIxrBKjIowvL9l+N66196+72XVYR8BBf1Uv1Fgt3bGevJ+sEmxfZzw== -vue@^2.6.11: - version "2.6.11" - resolved "https://registry.yarnpkg.com/vue/-/vue-2.6.11.tgz#76594d877d4b12234406e84e35275c6d514125c5" - integrity sha512-VfPwgcGABbGAue9+sfrD4PuwFar7gPb1yl1UK1MwXoQPAw0BKSqWfoYCT/ThFrdEVWoI51dBuyCoiNU9bZDZxQ== +vue@^2.6.12: + version "2.6.12" + resolved "https://registry.npm.taobao.org/vue/download/vue-2.6.12.tgz?cache=0&sync_timestamp=1603223843200&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fvue%2Fdownload%2Fvue-2.6.12.tgz#f5ebd4fa6bd2869403e29a896aed4904456c9123" + integrity sha1-9evU+mvShpQD4pqJau1JBEVskSM= w3c-hr-time@^1.0.1: version "1.0.2" From 66204dfcf11e971bc289fe66b43bfd75769e30ed Mon Sep 17 00:00:00 2001 From: neverland Date: Sun, 15 Nov 2020 15:14:13 +0800 Subject: [PATCH 4/5] fix(Sticky): not work in some cases (#7561) --- src/utils/dom/scroll.ts | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/src/utils/dom/scroll.ts b/src/utils/dom/scroll.ts index 6d7457f74..491847daa 100644 --- a/src/utils/dom/scroll.ts +++ b/src/utils/dom/scroll.ts @@ -5,8 +5,7 @@ function isWindow(val: unknown): val is Window { } // get nearest scroll element -// http://w3help.org/zh-cn/causes/SD9013 -// http://stackoverflow.com/questions/17016740/onscroll-function-is-not-working-for-chrome +// https://github.com/youzan/vant/issues/3823 const overflowScrollReg = /scroll|auto/i; export function getScroller(el: HTMLElement, root: ScrollElement = window) { let node = el; @@ -14,24 +13,13 @@ export function getScroller(el: HTMLElement, root: ScrollElement = window) { while ( node && node.tagName !== 'HTML' && + node.tagName !== 'BODY' && node.nodeType === 1 && node !== root ) { const { overflowY } = window.getComputedStyle(node); - if (overflowScrollReg.test(overflowY)) { - if (node.tagName !== 'BODY') { - return node; - } - - // see: https://github.com/youzan/vant/issues/3823 - const { overflowY: htmlOverflowY } = window.getComputedStyle( - node.parentNode as Element - ); - - if (overflowScrollReg.test(htmlOverflowY)) { - return node; - } + return node; } node = node.parentNode as HTMLElement; } From 5b4e063fa9e94a120670cabbfa54ca1f24a05233 Mon Sep 17 00:00:00 2001 From: neverland Date: Sun, 15 Nov 2020 15:33:49 +0800 Subject: [PATCH 5/5] fix(Swipe): leak when width has decimal (#7562) --- src/swipe/index.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/swipe/index.js b/src/swipe/index.js index fd18fdeff..947516082 100644 --- a/src/swipe/index.js +++ b/src/swipe/index.js @@ -167,8 +167,8 @@ export default createComponent({ this.rect = rect; this.swiping = true; this.active = active; - this.computedWidth = Math.floor(+this.width || rect.width); - this.computedHeight = Math.floor(+this.height || rect.height); + this.computedWidth = +this.width || rect.width; + this.computedHeight = +this.height || rect.height; this.offset = this.getTargetOffset(active); this.children.forEach((swipe) => { swipe.offset = 0; @@ -260,7 +260,7 @@ export default createComponent({ currentPosition = Math.min(currentPosition, -this.minOffset); } - let targetOffset = Math.round(offset - currentPosition); + let targetOffset = offset - currentPosition; if (!this.loop) { targetOffset = range(targetOffset, this.minOffset, 0); }