mirror of
https://gitee.com/vant-contrib/vant.git
synced 2026-06-05 09:58:11 +08:00
Compare commits
10 Commits
92f6a6a662
...
d8afff078a
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d8afff078a | ||
|
|
deb30d9683 | ||
|
|
16ff1ba9a7 | ||
|
|
3ddfe3bbb4 | ||
|
|
5fe263b601 | ||
|
|
f46f59fce2 | ||
|
|
a066e3a4bb | ||
|
|
d7bb080805 | ||
|
|
9c03f86088 | ||
|
|
9bb19819a5 |
@ -60,7 +60,7 @@
|
|||||||
"vue": "^3.0.0"
|
"vue": "^3.0.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@vant/cli": "^3.9.2",
|
"@vant/cli": "^3.10.0",
|
||||||
"@vant/area-data": "^1.0.0",
|
"@vant/area-data": "^1.0.0",
|
||||||
"@vue/compiler-sfc": "^3.0.6",
|
"@vue/compiler-sfc": "^3.0.6",
|
||||||
"prettier": "2.1.0",
|
"prettier": "2.1.0",
|
||||||
|
|||||||
@ -1,5 +1,18 @@
|
|||||||
# 更新日志
|
# 更新日志
|
||||||
|
|
||||||
|
## v3.10.0
|
||||||
|
|
||||||
|
`2021-04-10`
|
||||||
|
|
||||||
|
- 新增 `site.simulator` 选项
|
||||||
|
- 支持 iframe 通信跨域
|
||||||
|
|
||||||
|
## v3.9.3
|
||||||
|
|
||||||
|
`2021-04-10`
|
||||||
|
|
||||||
|
- 新增 `build.namedExport` 选项
|
||||||
|
|
||||||
## v3.9.2
|
## v3.9.2
|
||||||
|
|
||||||
`2021-04-04`
|
`2021-04-04`
|
||||||
|
|||||||
@ -5,6 +5,8 @@
|
|||||||
- [name](#name)
|
- [name](#name)
|
||||||
- [build.css](#buildcss)
|
- [build.css](#buildcss)
|
||||||
- [build.site](#buildsite)
|
- [build.site](#buildsite)
|
||||||
|
- [build.srcDir](#buildsrcdir)
|
||||||
|
- [build.namedExport](#buildnamedexport)
|
||||||
- [site.title](#sitetitle)
|
- [site.title](#sitetitle)
|
||||||
- [site.logo](#sitelogo)
|
- [site.logo](#sitelogo)
|
||||||
- [site.description](#sitedescription)
|
- [site.description](#sitedescription)
|
||||||
@ -13,6 +15,7 @@
|
|||||||
- [site.baiduAnalytics](#sitebaiduanalytics)
|
- [site.baiduAnalytics](#sitebaiduanalytics)
|
||||||
- [site.searchConfig](#sitesearchconfig)
|
- [site.searchConfig](#sitesearchconfig)
|
||||||
- [site.hideSimulator](#sitehidesimulator)
|
- [site.hideSimulator](#sitehidesimulator)
|
||||||
|
- [site.simulator.url](#sitesimulatorurl)
|
||||||
- [Webpack](#webpack)
|
- [Webpack](#webpack)
|
||||||
- [Babel](#babel)
|
- [Babel](#babel)
|
||||||
- [默认配置](#-1)
|
- [默认配置](#-1)
|
||||||
@ -124,6 +127,17 @@ module.exports = {
|
|||||||
};
|
};
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### build.namedExport
|
||||||
|
|
||||||
|
- Type: `boolean`
|
||||||
|
- Default: `false`
|
||||||
|
|
||||||
|
是否通过 Named Export 对组件进行导出。
|
||||||
|
|
||||||
|
未开启此选项时,会通过 `export default from 'xxx'` 导出组件内部的默认模块。
|
||||||
|
|
||||||
|
开启此选项后,会通过 `export * from 'xxx'` 导出组件内部的所有模块、类型定义。
|
||||||
|
|
||||||
### site.title
|
### site.title
|
||||||
|
|
||||||
- Type: `string`
|
- Type: `string`
|
||||||
@ -232,6 +246,13 @@ module.exports = {
|
|||||||
|
|
||||||
是否隐藏所有页面右侧的手机模拟器,默认不隐藏
|
是否隐藏所有页面右侧的手机模拟器,默认不隐藏
|
||||||
|
|
||||||
|
### site.simulator.url
|
||||||
|
|
||||||
|
- Type: `string`
|
||||||
|
- Default: -
|
||||||
|
|
||||||
|
自定义手机模拟器的 iframe URL 地址。
|
||||||
|
|
||||||
### site.htmlPluginOptions
|
### site.htmlPluginOptions
|
||||||
|
|
||||||
- Type: `object`
|
- Type: `object`
|
||||||
|
|||||||
@ -1,10 +1,10 @@
|
|||||||
{
|
{
|
||||||
"name": "@vant/cli",
|
"name": "@vant/cli",
|
||||||
"version": "3.9.2",
|
"version": "3.10.0",
|
||||||
"main": "lib/index.js",
|
"main": "lib/index.js",
|
||||||
"typings": "lib/index.d.ts",
|
"typings": "lib/index.d.ts",
|
||||||
"bin": {
|
"bin": {
|
||||||
"vant-cli": "./lib/index.js"
|
"vant-cli": "./lib/bin.js"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=10"
|
"node": ">=10"
|
||||||
|
|||||||
@ -2,28 +2,76 @@
|
|||||||
* 同步父窗口和 iframe 的 vue-router 状态
|
* 同步父窗口和 iframe 的 vue-router 状态
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { iframeReady, isMobile } from '.';
|
import { config } from 'site-desktop-shared';
|
||||||
|
|
||||||
window.syncPath = function() {
|
let queue = [];
|
||||||
|
let isIframeReady = false;
|
||||||
|
|
||||||
|
function iframeReady(callback) {
|
||||||
|
if (isIframeReady) {
|
||||||
|
callback();
|
||||||
|
} else {
|
||||||
|
queue.push(callback);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (window.top === window) {
|
||||||
|
window.addEventListener('message', (event) => {
|
||||||
|
if (event.data.type === 'iframeReady') {
|
||||||
|
isIframeReady = true;
|
||||||
|
queue.forEach((callback) => callback());
|
||||||
|
queue = [];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
window.top.postMessage({ type: 'iframeReady' }, '*');
|
||||||
|
}
|
||||||
|
|
||||||
|
function getCurrentDir() {
|
||||||
const router = window.vueRouter;
|
const router = window.vueRouter;
|
||||||
const isInIframe = window !== window.top;
|
const { path } = router.currentRoute.value;
|
||||||
const currentDir = router.currentRoute.value.path;
|
|
||||||
|
|
||||||
if (isInIframe) {
|
if (config.site.simulator?.routeMapper) {
|
||||||
window.top.replacePath(currentDir);
|
return config.site.simulator?.routeMapper(path);
|
||||||
} else if (!isMobile) {
|
}
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function syncPathToParent() {
|
||||||
|
window.top.postMessage(
|
||||||
|
{
|
||||||
|
type: 'replacePath',
|
||||||
|
value: getCurrentDir(),
|
||||||
|
},
|
||||||
|
'*'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function syncPathToChild() {
|
||||||
const iframe = document.querySelector('iframe');
|
const iframe = document.querySelector('iframe');
|
||||||
if (iframe) {
|
if (iframe) {
|
||||||
iframeReady(iframe, () => {
|
iframeReady(() => {
|
||||||
iframe.contentWindow.replacePath(currentDir);
|
iframe.contentWindow.postMessage(
|
||||||
|
{
|
||||||
|
type: 'replacePath',
|
||||||
|
value: getCurrentDir(),
|
||||||
|
},
|
||||||
|
'*'
|
||||||
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
window.replacePath = function(path = '') {
|
export function listenToSyncPath(router) {
|
||||||
// should preserve hash for anchor
|
window.addEventListener('message', (event) => {
|
||||||
if (window.vueRouter.currentRoute.value.path !== path) {
|
if (event.data?.type !== 'replacePath') {
|
||||||
window.vueRouter.replace(path).catch(() => {});
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const path = event.data?.value || '';
|
||||||
|
// should preserve hash for anchor
|
||||||
|
if (router.currentRoute.value.path !== path) {
|
||||||
|
router.replace(path).catch(() => {});
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|||||||
@ -1,20 +1,3 @@
|
|||||||
function iframeReady(iframe, callback) {
|
|
||||||
const doc = iframe.contentDocument || iframe.contentWindow.document;
|
|
||||||
const interval = () => {
|
|
||||||
if (iframe.contentWindow.replacePath) {
|
|
||||||
callback();
|
|
||||||
} else {
|
|
||||||
setTimeout(interval, 50);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
if (doc.readyState === 'complete') {
|
|
||||||
interval();
|
|
||||||
} else {
|
|
||||||
iframe.onload = interval;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const ua = navigator.userAgent.toLowerCase();
|
const ua = navigator.userAgent.toLowerCase();
|
||||||
const isMobile = /ios|iphone|ipod|ipad|android/.test(ua);
|
const isMobile = /ios|iphone|ipod|ipad|android/.test(ua);
|
||||||
|
|
||||||
@ -25,4 +8,4 @@ export function decamelize(str, sep = '-') {
|
|||||||
.toLowerCase();
|
.toLowerCase();
|
||||||
}
|
}
|
||||||
|
|
||||||
export { isMobile, iframeReady };
|
export { isMobile };
|
||||||
|
|||||||
@ -25,15 +25,20 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
data() {
|
data() {
|
||||||
const path = location.pathname.replace(/\/index(\.html)?/, '/');
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
simulator: `${path}mobile.html${location.hash}`,
|
|
||||||
hasSimulator: true,
|
hasSimulator: true,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
computed: {
|
computed: {
|
||||||
|
simulator() {
|
||||||
|
if (config.site.simulator?.url) {
|
||||||
|
return config.site.simulator?.url;
|
||||||
|
}
|
||||||
|
const path = location.pathname.replace(/\/index(\.html)?/, '/');
|
||||||
|
return `${path}mobile.html${location.hash}`;
|
||||||
|
},
|
||||||
|
|
||||||
lang() {
|
lang() {
|
||||||
const { lang } = this.$route.meta;
|
const { lang } = this.$route.meta;
|
||||||
return lang || '';
|
return lang || '';
|
||||||
|
|||||||
@ -214,7 +214,7 @@ export default {
|
|||||||
position: absolute;
|
position: absolute;
|
||||||
top: 34px;
|
top: 34px;
|
||||||
left: 0;
|
left: 0;
|
||||||
width: 100px;
|
width: 100%;
|
||||||
z-index: 99;
|
z-index: 99;
|
||||||
color: #333;
|
color: #333;
|
||||||
line-height: 36px;
|
line-height: 36px;
|
||||||
|
|||||||
@ -3,7 +3,7 @@ import { createRouter, createWebHashHistory } from 'vue-router';
|
|||||||
import { isMobile, decamelize } from '../common';
|
import { isMobile, decamelize } from '../common';
|
||||||
import { config, documents } from 'site-desktop-shared';
|
import { config, documents } from 'site-desktop-shared';
|
||||||
import { getLang, setDefaultLang } from '../common/locales';
|
import { getLang, setDefaultLang } from '../common/locales';
|
||||||
import '../common/iframe-router';
|
import { listenToSyncPath, syncPathToChild } from '../common/iframe-router';
|
||||||
|
|
||||||
if (isMobile) {
|
if (isMobile) {
|
||||||
location.replace('mobile.html' + location.hash);
|
location.replace('mobile.html' + location.hash);
|
||||||
@ -117,7 +117,11 @@ export const router = createRouter({
|
|||||||
});
|
});
|
||||||
|
|
||||||
router.afterEach(() => {
|
router.afterEach(() => {
|
||||||
nextTick(() => window.syncPath());
|
nextTick(syncPathToChild);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (config.site.simulator?.syncPathFromSimulator !== false) {
|
||||||
|
listenToSyncPath(router);
|
||||||
|
}
|
||||||
|
|
||||||
window.vueRouter = router;
|
window.vueRouter = router;
|
||||||
|
|||||||
@ -4,7 +4,7 @@ import DemoHome from './components/DemoHome';
|
|||||||
import { decamelize } from '../common';
|
import { decamelize } from '../common';
|
||||||
import { demos, config } from 'site-mobile-shared';
|
import { demos, config } from 'site-mobile-shared';
|
||||||
import { getLang, setDefaultLang } from '../common/locales';
|
import { getLang, setDefaultLang } from '../common/locales';
|
||||||
import '../common/iframe-router';
|
import { listenToSyncPath, syncPathToParent } from '../common/iframe-router';
|
||||||
|
|
||||||
const { locales, defaultLang } = config.site;
|
const { locales, defaultLang } = config.site;
|
||||||
|
|
||||||
@ -97,8 +97,10 @@ export const router = createRouter({
|
|||||||
|
|
||||||
watch(router.currentRoute, () => {
|
watch(router.currentRoute, () => {
|
||||||
if (!router.currentRoute.value.redirectedFrom) {
|
if (!router.currentRoute.value.redirectedFrom) {
|
||||||
nextTick(window.syncPath);
|
nextTick(syncPathToParent);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
listenToSyncPath(router);
|
||||||
|
|
||||||
window.vueRouter = router;
|
window.vueRouter = router;
|
||||||
|
|||||||
57
packages/vant-cli/src/bin.ts
Normal file
57
packages/vant-cli/src/bin.ts
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
import { command, parse, version } from 'commander';
|
||||||
|
|
||||||
|
import {
|
||||||
|
dev,
|
||||||
|
lint,
|
||||||
|
test,
|
||||||
|
clean,
|
||||||
|
build,
|
||||||
|
release,
|
||||||
|
changelog,
|
||||||
|
buildSite,
|
||||||
|
commitLint,
|
||||||
|
cliVersion,
|
||||||
|
} from '.';
|
||||||
|
|
||||||
|
version(`@vant/cli ${cliVersion}`);
|
||||||
|
|
||||||
|
command('dev').description('Run webpack dev server').action(dev);
|
||||||
|
|
||||||
|
command('lint').description('Run eslint and stylelint').action(lint);
|
||||||
|
|
||||||
|
command('test')
|
||||||
|
.description('Run unit tests through jest')
|
||||||
|
.option(
|
||||||
|
'--watch',
|
||||||
|
'Watch files for changes and rerun tests related to changed files'
|
||||||
|
)
|
||||||
|
.option(
|
||||||
|
'--clearCache',
|
||||||
|
'Clears the configured Jest cache directory and then exits'
|
||||||
|
)
|
||||||
|
.action(test);
|
||||||
|
|
||||||
|
command('clean').description('Clean all dist files').action(clean);
|
||||||
|
|
||||||
|
command('build')
|
||||||
|
.description('Compile components in production mode')
|
||||||
|
.option('--watch', 'Watch file change')
|
||||||
|
.action(build);
|
||||||
|
|
||||||
|
command('release')
|
||||||
|
.description('Compile components and release it')
|
||||||
|
.option('--tag <tag>', 'Release tag')
|
||||||
|
.action(release);
|
||||||
|
|
||||||
|
command('build-site')
|
||||||
|
.description('Compile site in production mode')
|
||||||
|
.action(buildSite);
|
||||||
|
|
||||||
|
command('changelog').description('Generate changelog').action(changelog);
|
||||||
|
|
||||||
|
command('commit-lint <gitParams>')
|
||||||
|
.description('Lint commit message')
|
||||||
|
.action(commitLint);
|
||||||
|
|
||||||
|
parse();
|
||||||
@ -8,36 +8,77 @@ import {
|
|||||||
} from '../common';
|
} from '../common';
|
||||||
import { SRC_DIR, getPackageJson, getVantConfig } from '../common/constant';
|
import { SRC_DIR, getPackageJson, getVantConfig } from '../common/constant';
|
||||||
|
|
||||||
type Options = {
|
type PathResolver = (path: string) => string;
|
||||||
outputPath: string;
|
|
||||||
pathResolver?: Function;
|
|
||||||
};
|
|
||||||
|
|
||||||
function genImports(components: string[], options: Options): string {
|
function getPathByName(name: string, pathResolver?: PathResolver) {
|
||||||
return components
|
|
||||||
.map((name) => {
|
|
||||||
let path = join(SRC_DIR, name);
|
let path = join(SRC_DIR, name);
|
||||||
if (options.pathResolver) {
|
if (pathResolver) {
|
||||||
path = options.pathResolver(path);
|
path = pathResolver(path);
|
||||||
|
}
|
||||||
|
return normalizePath(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
return `import ${pascalize(name)} from '${normalizePath(path)}';`;
|
function genImports(
|
||||||
|
names: string[],
|
||||||
|
pathResolver?: PathResolver,
|
||||||
|
namedExport?: boolean
|
||||||
|
): string {
|
||||||
|
return names
|
||||||
|
.map((name) => {
|
||||||
|
const pascalName = pascalize(name);
|
||||||
|
const importName = namedExport ? `{ ${pascalName} }` : pascalName;
|
||||||
|
const importPath = getPathByName(name, pathResolver);
|
||||||
|
|
||||||
|
return `import ${importName} from '${importPath}';`;
|
||||||
})
|
})
|
||||||
.join('\n');
|
.join('\n');
|
||||||
}
|
}
|
||||||
|
|
||||||
function genExports(names: string[]): string {
|
function genExports(
|
||||||
return names.map((name) => `${name}`).join(',\n ');
|
names: string[],
|
||||||
|
pathResolver?: PathResolver,
|
||||||
|
namedExport?: boolean
|
||||||
|
): string {
|
||||||
|
if (namedExport) {
|
||||||
|
const exports = names
|
||||||
|
.map((name) => `export * from '${getPathByName(name, pathResolver)}';`)
|
||||||
|
.join('\n');
|
||||||
|
|
||||||
|
return `
|
||||||
|
export {
|
||||||
|
install,
|
||||||
|
version,
|
||||||
|
};
|
||||||
|
${exports}
|
||||||
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function genPackageEntry(options: Options) {
|
return `
|
||||||
|
export {
|
||||||
|
install,
|
||||||
|
version,
|
||||||
|
${names.map(pascalize).join(',\n ')}
|
||||||
|
};
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function genPackageEntry({
|
||||||
|
outputPath,
|
||||||
|
pathResolver,
|
||||||
|
}: {
|
||||||
|
outputPath: string;
|
||||||
|
pathResolver?: PathResolver;
|
||||||
|
}) {
|
||||||
const names = getComponents();
|
const names = getComponents();
|
||||||
const vantConfig = getVantConfig();
|
const vantConfig = getVantConfig();
|
||||||
|
|
||||||
|
const namedExport = get(vantConfig, 'build.namedExport', false);
|
||||||
const skipInstall = get(vantConfig, 'build.skipInstall', []).map(pascalize);
|
const skipInstall = get(vantConfig, 'build.skipInstall', []).map(pascalize);
|
||||||
|
|
||||||
const version = process.env.PACKAGE_VERSION || getPackageJson().version;
|
const version = process.env.PACKAGE_VERSION || getPackageJson().version;
|
||||||
|
|
||||||
const components = names.map(pascalize);
|
const components = names.map(pascalize);
|
||||||
const content = `${genImports(names, options)}
|
const content = `${genImports(names, pathResolver, namedExport)}
|
||||||
|
|
||||||
const version = '${version}';
|
const version = '${version}';
|
||||||
|
|
||||||
@ -55,11 +96,7 @@ function install(app) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export {
|
${genExports(names, pathResolver, namedExport)}
|
||||||
install,
|
|
||||||
version,
|
|
||||||
${genExports(components)}
|
|
||||||
};
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
install,
|
install,
|
||||||
@ -67,5 +104,5 @@ export default {
|
|||||||
};
|
};
|
||||||
`;
|
`;
|
||||||
|
|
||||||
smartOutputFile(options.outputPath, content);
|
smartOutputFile(outputPath, content);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -17,25 +17,25 @@ module.exports = function (api?: ConfigAPI, options: PresetOption = {}) {
|
|||||||
return {
|
return {
|
||||||
presets: [
|
presets: [
|
||||||
[
|
[
|
||||||
'@babel/preset-env',
|
require.resolve('@babel/preset-env'),
|
||||||
{
|
{
|
||||||
modules: useESModules ? false : 'commonjs',
|
modules: useESModules ? false : 'commonjs',
|
||||||
loose: options.loose,
|
loose: options.loose,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
'@babel/preset-typescript',
|
require.resolve('@babel/preset-typescript'),
|
||||||
require('../compiler/babel-preset-vue-ts'),
|
require('../compiler/babel-preset-vue-ts'),
|
||||||
],
|
],
|
||||||
plugins: [
|
plugins: [
|
||||||
[
|
[
|
||||||
'@babel/plugin-transform-runtime',
|
require.resolve('@babel/plugin-transform-runtime'),
|
||||||
{
|
{
|
||||||
corejs: false,
|
corejs: false,
|
||||||
useESModules,
|
useESModules,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'import',
|
require.resolve('babel-plugin-import'),
|
||||||
{
|
{
|
||||||
libraryName: 'vant',
|
libraryName: 'vant',
|
||||||
libraryDirectory: useESModules ? 'es' : 'lib',
|
libraryDirectory: useESModules ? 'es' : 'lib',
|
||||||
@ -44,7 +44,7 @@ module.exports = function (api?: ConfigAPI, options: PresetOption = {}) {
|
|||||||
'vant',
|
'vant',
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'@vue/babel-plugin-jsx',
|
require.resolve('@vue/babel-plugin-jsx'),
|
||||||
{
|
{
|
||||||
enableObjectSlots: options.enableObjectSlots,
|
enableObjectSlots: options.enableObjectSlots,
|
||||||
},
|
},
|
||||||
|
|||||||
@ -14,10 +14,10 @@ import {
|
|||||||
} from '../common/constant';
|
} from '../common/constant';
|
||||||
|
|
||||||
const CSS_LOADERS = [
|
const CSS_LOADERS = [
|
||||||
'style-loader',
|
require.resolve('style-loader'),
|
||||||
'css-loader',
|
require.resolve('css-loader'),
|
||||||
{
|
{
|
||||||
loader: 'postcss-loader',
|
loader: require.resolve('postcss-loader'),
|
||||||
options: {
|
options: {
|
||||||
postcssOptions: require(POSTCSS_CONFIG_FILE),
|
postcssOptions: require(POSTCSS_CONFIG_FILE),
|
||||||
},
|
},
|
||||||
@ -25,7 +25,7 @@ const CSS_LOADERS = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
const VUE_LOADER = {
|
const VUE_LOADER = {
|
||||||
loader: 'vue-loader',
|
loader: require.resolve('vue-loader'),
|
||||||
options: {
|
options: {
|
||||||
compilerOptions: {
|
compilerOptions: {
|
||||||
preserveWhitespace: false,
|
preserveWhitespace: false,
|
||||||
@ -88,7 +88,7 @@ export const baseConfig: WebpackConfig = {
|
|||||||
{
|
{
|
||||||
test: /\.(js|ts|jsx|tsx)$/,
|
test: /\.(js|ts|jsx|tsx)$/,
|
||||||
exclude: /node_modules\/(?!(@vant\/cli))/,
|
exclude: /node_modules\/(?!(@vant\/cli))/,
|
||||||
use: ['babel-loader'],
|
use: [require.resolve('babel-loader')],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
test: /\.css$/,
|
test: /\.css$/,
|
||||||
@ -98,7 +98,7 @@ export const baseConfig: WebpackConfig = {
|
|||||||
{
|
{
|
||||||
test: /\.less$/,
|
test: /\.less$/,
|
||||||
sideEffects: true,
|
sideEffects: true,
|
||||||
use: [...CSS_LOADERS, 'less-loader'],
|
use: [...CSS_LOADERS, require.resolve('less-loader')],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
test: /\.scss$/,
|
test: /\.scss$/,
|
||||||
@ -106,7 +106,7 @@ export const baseConfig: WebpackConfig = {
|
|||||||
use: [
|
use: [
|
||||||
...CSS_LOADERS,
|
...CSS_LOADERS,
|
||||||
{
|
{
|
||||||
loader: 'sass-loader',
|
loader: require.resolve('sass-loader'),
|
||||||
options: {
|
options: {
|
||||||
implementation: sass,
|
implementation: sass,
|
||||||
},
|
},
|
||||||
@ -115,7 +115,7 @@ export const baseConfig: WebpackConfig = {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
test: /\.md$/,
|
test: /\.md$/,
|
||||||
use: [VUE_LOADER, '@vant/markdown-loader'],
|
use: [VUE_LOADER, require.resolve('@vant/markdown-loader')],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
|||||||
@ -1,10 +1,5 @@
|
|||||||
#!/usr/bin/env node
|
|
||||||
import { command, parse, version } from 'commander';
|
|
||||||
|
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
import packageJson from '../package.json';
|
import packageJson from '../package.json';
|
||||||
|
|
||||||
// commands
|
|
||||||
import { dev } from './commands/dev';
|
import { dev } from './commands/dev';
|
||||||
import { lint } from './commands/lint';
|
import { lint } from './commands/lint';
|
||||||
import { test } from './commands/jest';
|
import { test } from './commands/jest';
|
||||||
@ -15,46 +10,18 @@ import { changelog } from './commands/changelog';
|
|||||||
import { buildSite } from './commands/build-site';
|
import { buildSite } from './commands/build-site';
|
||||||
import { commitLint } from './commands/commit-lint';
|
import { commitLint } from './commands/commit-lint';
|
||||||
|
|
||||||
version(`@vant/cli ${packageJson.version}`);
|
export const cliVersion: string = packageJson.version;
|
||||||
|
|
||||||
process.env.VANT_CLI_VERSION = packageJson.version;
|
process.env.VANT_CLI_VERSION = cliVersion;
|
||||||
|
|
||||||
command('dev').description('Run webpack dev server').action(dev);
|
export {
|
||||||
|
dev,
|
||||||
command('lint').description('Run eslint and stylelint').action(lint);
|
lint,
|
||||||
|
test,
|
||||||
command('test')
|
clean,
|
||||||
.description('Run unit tests through jest')
|
build,
|
||||||
.option(
|
release,
|
||||||
'--watch',
|
changelog,
|
||||||
'Watch files for changes and rerun tests related to changed files'
|
buildSite,
|
||||||
)
|
commitLint,
|
||||||
.option(
|
};
|
||||||
'--clearCache',
|
|
||||||
'Clears the configured Jest cache directory and then exits'
|
|
||||||
)
|
|
||||||
.action(test);
|
|
||||||
|
|
||||||
command('clean').description('Clean all dist files').action(clean);
|
|
||||||
|
|
||||||
command('build')
|
|
||||||
.description('Compile components in production mode')
|
|
||||||
.option('--watch', 'Watch file change')
|
|
||||||
.action(build);
|
|
||||||
|
|
||||||
command('release')
|
|
||||||
.description('Compile components and release it')
|
|
||||||
.option('--tag <tag>', 'Release tag')
|
|
||||||
.action(release);
|
|
||||||
|
|
||||||
command('build-site')
|
|
||||||
.description('Compile site in production mode')
|
|
||||||
.action(buildSite);
|
|
||||||
|
|
||||||
command('changelog').description('Generate changelog').action(changelog);
|
|
||||||
|
|
||||||
command('commit-lint <gitParams>')
|
|
||||||
.description('Lint commit message')
|
|
||||||
.action(commitLint);
|
|
||||||
|
|
||||||
parse();
|
|
||||||
|
|||||||
@ -10,7 +10,7 @@ const messages = reactive<Messages>({
|
|||||||
'zh-CN': defaultMessages,
|
'zh-CN': defaultMessages,
|
||||||
});
|
});
|
||||||
|
|
||||||
export default {
|
const Locale = {
|
||||||
messages(): Message {
|
messages(): Message {
|
||||||
return messages[lang.value];
|
return messages[lang.value];
|
||||||
},
|
},
|
||||||
@ -24,3 +24,6 @@ export default {
|
|||||||
deepAssign(messages, newMessages);
|
deepAssign(messages, newMessages);
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export default Locale;
|
||||||
|
export { Locale };
|
||||||
|
|||||||
@ -2,6 +2,7 @@ module.exports = {
|
|||||||
name: 'vant',
|
name: 'vant',
|
||||||
build: {
|
build: {
|
||||||
srcDir: 'src',
|
srcDir: 'src',
|
||||||
|
namedExport: true,
|
||||||
skipInstall: ['lazyload'],
|
skipInstall: ['lazyload'],
|
||||||
site: {
|
site: {
|
||||||
publicPath:
|
publicPath:
|
||||||
@ -15,9 +16,8 @@ module.exports = {
|
|||||||
site: {
|
site: {
|
||||||
defaultLang: 'en-US',
|
defaultLang: 'en-US',
|
||||||
versions: [
|
versions: [
|
||||||
{ label: 'Vant v1', link: '/vant/v1/' },
|
{ label: 'v1', link: '/vant/v1/' },
|
||||||
{ label: 'Vant v2', link: '/vant/' },
|
{ label: 'v2', link: '/vant/' },
|
||||||
{ label: 'Vant Weapp', link: '/vant-weapp/' },
|
|
||||||
],
|
],
|
||||||
baiduAnalytics: {
|
baiduAnalytics: {
|
||||||
seed: 'ad6b5732c36321f2dafed737ac2da92f',
|
seed: 'ad6b5732c36321f2dafed737ac2da92f',
|
||||||
@ -30,10 +30,14 @@ module.exports = {
|
|||||||
locales: {
|
locales: {
|
||||||
'zh-CN': {
|
'zh-CN': {
|
||||||
title: 'Vant',
|
title: 'Vant',
|
||||||
description: '轻量、可靠的移动端 Vue 组件库',
|
description: '轻量、可靠的移动端组件库',
|
||||||
logo: 'https://img.yzcdn.cn/vant/logo.png',
|
logo: 'https://img.yzcdn.cn/vant/logo.png',
|
||||||
langLabel: '中',
|
langLabel: '中',
|
||||||
links: [
|
links: [
|
||||||
|
{
|
||||||
|
logo: 'https://b.yzcdn.cn/vant/logo/weapp.svg',
|
||||||
|
url: 'https://vant-contrib.gitee.io/vant-weapp/',
|
||||||
|
},
|
||||||
{
|
{
|
||||||
logo: 'https://b.yzcdn.cn/vant/logo/github.svg',
|
logo: 'https://b.yzcdn.cn/vant/logo/github.svg',
|
||||||
url: 'https://github.com/youzan/vant',
|
url: 'https://github.com/youzan/vant',
|
||||||
|
|||||||
@ -1860,10 +1860,10 @@
|
|||||||
resolved "https://registry.npm.taobao.org/@vant/area-data/download/@vant/area-data-1.0.0.tgz#063af9ccb5ccafa333d7dc28103937501cfec671"
|
resolved "https://registry.npm.taobao.org/@vant/area-data/download/@vant/area-data-1.0.0.tgz#063af9ccb5ccafa333d7dc28103937501cfec671"
|
||||||
integrity sha1-Bjr5zLXMr6Mz19woEDk3UBz+xnE=
|
integrity sha1-Bjr5zLXMr6Mz19woEDk3UBz+xnE=
|
||||||
|
|
||||||
"@vant/cli@^3.9.2":
|
"@vant/cli@^3.10.0":
|
||||||
version "3.9.2"
|
version "3.10.0"
|
||||||
resolved "https://registry.npm.taobao.org/@vant/cli/download/@vant/cli-3.9.2.tgz#6eb7149004c8b36bc5fc08c16cc36c78bcdd3b4b"
|
resolved "https://registry.npmjs.org/@vant/cli/-/cli-3.10.0.tgz#a129adb56f15a3c31a7a2701e288ed9a642e734d"
|
||||||
integrity sha1-brcUkATIs2vF/AjBbMNseLzdO0s=
|
integrity sha512-+Nj6YHxYgsgmDFrS31PiT2UwB70KO5EH3QLbzYDihoj0QfYEQmHdk+DAOeZ6IXgZR5Nb3EbZFFLKmebngYaisg==
|
||||||
dependencies:
|
dependencies:
|
||||||
"@babel/core" "^7.12.10"
|
"@babel/core" "^7.12.10"
|
||||||
"@babel/plugin-transform-runtime" "^7.12.10"
|
"@babel/plugin-transform-runtime" "^7.12.10"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user