diff --git a/docs/site/mobile.js b/docs/site/mobile.js index a27993dd5..8757dcc0e 100644 --- a/docs/site/mobile.js +++ b/docs/site/mobile.js @@ -1,130 +1,130 @@ -import Vue from 'vue'; -import Locale from '../../src/locale'; -import Lazyload from '../../src/lazyload'; -import { get } from '../../src/utils'; -import { camelize } from '../../src/utils/format/string'; -import enUS from '../../src/locale/lang/en-US'; +// import Vue from 'vue'; +// import Locale from '../../src/locale'; +// import Lazyload from '../../src/lazyload'; +// import { get } from '../../src/utils'; +// import { camelize } from '../../src/utils/format/string'; +// import enUS from '../../src/locale/lang/en-US'; -Vue.use(Lazyload, { - lazyComponent: true, -}); +// Vue.use(Lazyload, { +// lazyComponent: true, +// }); -Locale.add({ - 'en-US': enUS, -}); +// Locale.add({ +// 'en-US': enUS, +// }); -// flag for vant-weapp demos -const isWeapp = location.search.indexOf('weapp=1') !== -1; +// // flag for vant-weapp demos +// const isWeapp = location.search.indexOf('weapp=1') !== -1; -let demoUid = 0; +// let demoUid = 0; -// helper for demo locales -Vue.mixin({ - computed: { - t() { - const { name } = this.$options; - const { lang = 'zh-CN' } = (this.$route && this.$route.meta) || {}; - const prefix = name ? camelize(name) + '.' : ''; - const messages = this.$vantMessages[lang]; +// // helper for demo locales +// Vue.mixin({ +// computed: { +// t() { +// const { name } = this.$options; +// const { lang = 'zh-CN' } = (this.$route && this.$route.meta) || {}; +// const prefix = name ? camelize(name) + '.' : ''; +// const messages = this.$vantMessages[lang]; - return (path, ...args) => { - const message = get(messages, prefix + path) || get(messages, path); - return typeof message === 'function' ? message(...args) : message; - }; - }, +// return (path, ...args) => { +// const message = get(messages, prefix + path) || get(messages, path); +// return typeof message === 'function' ? message(...args) : message; +// }; +// }, - isWeapp() { - return isWeapp; - }, - }, +// isWeapp() { +// return isWeapp; +// }, +// }, - beforeCreate() { - if (!this.$options.name) { - this.$options.name = `demo-${demoUid++}`; - } +// beforeCreate() { +// if (!this.$options.name) { +// this.$options.name = `demo-${demoUid++}`; +// } - const { i18n, name } = this.$options; +// const { i18n, name } = this.$options; - if (i18n && name) { - const locales = {}; - const camelizedName = camelize(name); +// if (i18n && name) { +// const locales = {}; +// const camelizedName = camelize(name); - Object.keys(i18n).forEach((key) => { - locales[key] = { [camelizedName]: i18n[key] }; - }); +// Object.keys(i18n).forEach((key) => { +// locales[key] = { [camelizedName]: i18n[key] }; +// }); - Locale.add(locales); - } - }, -}); +// Locale.add(locales); +// } +// }, +// }); -// switch lang after routing -if (window.vueRouter) { - window.vueRouter.afterEach((to) => { - const { lang } = to.meta || {}; +// // switch lang after routing +// if (window.vueRouter) { +// window.vueRouter.afterEach((to) => { +// const { lang } = to.meta || {}; - if (lang) { - Locale.use(lang); - } - }); -} +// if (lang) { +// Locale.use(lang); +// } +// }); +// } -// add some basic locale messages -Locale.add({ - 'zh-CN': { - add: '增加', - decrease: '减少', - red: '红色', - orange: '橙色', - yellow: '黄色', - purple: '紫色', - tab: '标签', - tag: '标签', - desc: '描述信息', - back: '返回', - title: '标题', - status: '状态', - button: '按钮', - option: '选项', - search: '搜索', - content: '内容', - custom: '自定义', - username: '用户名', - password: '密码', - disabled: '禁用状态', - uneditable: '不可编辑', - basicUsage: '基础用法', - advancedUsage: '高级用法', - loadingStatus: '加载状态', - usernamePlaceholder: '请输入用户名', - passwordPlaceholder: '请输入密码', - }, - 'en-US': { - add: 'Add', - decrease: 'Decrease', - red: 'Red', - orange: 'Orange', - yellow: 'Yellow', - purple: 'Purple', - tab: 'Tab', - tag: 'Tag', - desc: 'Description', - back: 'Back', - title: 'Title', - status: 'Status', - button: 'Button', - option: 'Option', - search: 'Search', - content: 'Content', - custom: 'Custom', - username: 'Username', - password: 'Password', - loadingStatus: 'Loading', - disabled: 'Disabled', - uneditable: 'Uneditable', - basicUsage: 'Basic Usage', - advancedUsage: 'Advanced Usage', - usernamePlaceholder: 'Username', - passwordPlaceholder: 'Password', - }, -}); +// // add some basic locale messages +// Locale.add({ +// 'zh-CN': { +// add: '增加', +// decrease: '减少', +// red: '红色', +// orange: '橙色', +// yellow: '黄色', +// purple: '紫色', +// tab: '标签', +// tag: '标签', +// desc: '描述信息', +// back: '返回', +// title: '标题', +// status: '状态', +// button: '按钮', +// option: '选项', +// search: '搜索', +// content: '内容', +// custom: '自定义', +// username: '用户名', +// password: '密码', +// disabled: '禁用状态', +// uneditable: '不可编辑', +// basicUsage: '基础用法', +// advancedUsage: '高级用法', +// loadingStatus: '加载状态', +// usernamePlaceholder: '请输入用户名', +// passwordPlaceholder: '请输入密码', +// }, +// 'en-US': { +// add: 'Add', +// decrease: 'Decrease', +// red: 'Red', +// orange: 'Orange', +// yellow: 'Yellow', +// purple: 'Purple', +// tab: 'Tab', +// tag: 'Tag', +// desc: 'Description', +// back: 'Back', +// title: 'Title', +// status: 'Status', +// button: 'Button', +// option: 'Option', +// search: 'Search', +// content: 'Content', +// custom: 'Custom', +// username: 'Username', +// password: 'Password', +// loadingStatus: 'Loading', +// disabled: 'Disabled', +// uneditable: 'Uneditable', +// basicUsage: 'Basic Usage', +// advancedUsage: 'Advanced Usage', +// usernamePlaceholder: 'Username', +// passwordPlaceholder: 'Password', +// }, +// }); diff --git a/packages/vant-cli/src/compiler/compile-sfc.ts b/packages/vant-cli/src/compiler/compile-sfc.ts index 0a162e3c9..0bee1615a 100644 --- a/packages/vant-cli/src/compiler/compile-sfc.ts +++ b/packages/vant-cli/src/compiler/compile-sfc.ts @@ -1,4 +1,4 @@ -import * as compiler from 'vue-template-compiler'; +import * as compiler from '@vue/compiler-sfc'; import * as compileUtils from '@vue/component-compiler-utils'; import hash from 'hash-sum'; import { parse } from 'path'; @@ -87,7 +87,7 @@ export async function compileSfc(filePath: string): Promise { const descriptor = parseSfc(filePath); const { template, styles } = descriptor; - const hasScoped = styles.some(s => s.scoped); + const hasScoped = styles.some((s) => s.scoped); const scopeId = hasScoped ? `data-v-${hash(source)}` : ''; // compile js part @@ -107,9 +107,7 @@ export async function compileSfc(filePath: string): Promise { } writeFileSync(jsFilePath, script); - compileJs(jsFilePath) - .then(resolve) - .catch(reject); + compileJs(jsFilePath).then(resolve).catch(reject); }) ); } diff --git a/packages/vant-cli/src/config/jest.setup.ts b/packages/vant-cli/src/config/jest.setup.ts index 28e007f28..fe45ee917 100644 --- a/packages/vant-cli/src/config/jest.setup.ts +++ b/packages/vant-cli/src/config/jest.setup.ts @@ -1,6 +1,6 @@ -import Vue from 'vue'; +// import Vue from 'vue'; import 'jest-canvas-mock'; // @ts-ignore -import Package from '../../dist/package-entry'; +// import Package from '../../dist/package-entry'; -Vue.use(Package); +// Vue.use(Package); diff --git a/packages/vant-cli/src/config/webpack.base.ts b/packages/vant-cli/src/config/webpack.base.ts index 461869b01..59b53b7b4 100644 --- a/packages/vant-cli/src/config/webpack.base.ts +++ b/packages/vant-cli/src/config/webpack.base.ts @@ -40,26 +40,26 @@ const plugins = [ }), ]; -const tsconfigPath = join(CWD, 'tsconfig.json'); -if (existsSync(tsconfigPath)) { - const ForkTsCheckerPlugin = require('fork-ts-checker-webpack-plugin'); - plugins.push( - new ForkTsCheckerPlugin({ - formatter: 'codeframe', - vue: { enabled: true }, - logger: { - // skip info message - info() {}, - warn(message: string) { - consola.warn(message); - }, - error(message: string) { - consola.error(message); - }, - }, - }) - ); -} +// const tsconfigPath = join(CWD, 'tsconfig.json'); +// if (existsSync(tsconfigPath)) { +// const ForkTsCheckerPlugin = require('fork-ts-checker-webpack-plugin'); +// plugins.push( +// new ForkTsCheckerPlugin({ +// formatter: 'codeframe', +// vue: { enabled: true }, +// logger: { +// // skip info message +// info() {}, +// warn(message: string) { +// consola.warn(message); +// }, +// error(message: string) { +// consola.error(message); +// }, +// }, +// }) +// ); +// } export const baseConfig = { mode: 'development', @@ -112,7 +112,7 @@ export const baseConfig = { }, { test: /\.md$/, - use: [CACHE_LOADER, 'vue-loader', '@vant/markdown-loader'], + use: [CACHE_LOADER, '@vant/markdown-loader'], }, ], },