diff --git a/.github/workflows/codecov.yml b/.github/workflows/codecov.yml index 135820499..45dcb53e6 100644 --- a/.github/workflows/codecov.yml +++ b/.github/workflows/codecov.yml @@ -44,14 +44,6 @@ jobs: with: token: ${{ secrets.ACCESS_TOKEN }} - - name: Checkout submodules - uses: actions/checkout@v2 - with: - repository: tangjinzhou/antdv-demo - token: ${{ secrets.ACCESS_TOKEN }} - path: antdv-demo - submodules: true - - name: restore cache from package-lock.json uses: actions/cache@v1 with: diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index 7f234816c..000000000 --- a/.gitmodules +++ /dev/null @@ -1,3 +0,0 @@ -[submodule "antdv-demo"] - path = antdv-demo - url = git@github.com:tangjinzhou/antdv-demo.git diff --git a/antdv-demo/.babelrc b/antdv-demo/.babelrc new file mode 100644 index 000000000..1321e4c34 --- /dev/null +++ b/antdv-demo/.babelrc @@ -0,0 +1,14 @@ +{ + "env": { + "test": { + "presets": [["env", { "targets": { "node": "current" } }]], + "plugins": [ + "transform-vue-jsx", + "transform-object-assign", + "transform-object-rest-spread", + "transform-class-properties", + "transform-runtime" + ] + } + } +} diff --git a/antdv-demo/.editorconfig b/antdv-demo/.editorconfig new file mode 100644 index 000000000..4c7f8a8ef --- /dev/null +++ b/antdv-demo/.editorconfig @@ -0,0 +1,11 @@ +# 🎨 editorconfig.org + +root = true + +[*] +charset = utf-8 +end_of_line = lf +indent_style = space +indent_size = 2 +trim_trailing_whitespace = true +insert_final_newline = true \ No newline at end of file diff --git a/antdv-demo/.eslintignore b/antdv-demo/.eslintignore new file mode 100644 index 000000000..de421fd3e --- /dev/null +++ b/antdv-demo/.eslintignore @@ -0,0 +1,8 @@ +node_modules/ +**/*.spec.* +**/style/ +*.html +/components/test/* +_site/ +dist/ +package.json diff --git a/antdv-demo/.eslintrc b/antdv-demo/.eslintrc new file mode 100644 index 000000000..6d1be14cc --- /dev/null +++ b/antdv-demo/.eslintrc @@ -0,0 +1,53 @@ +{ + "root": true, + "env": { + "browser": true, + "node": true, + "jasmine": true, + "jest": true, + "es6": true + }, + "parserOptions": { + "parser": "babel-eslint" + }, + "extends": ["plugin:vue/recommended", "prettier"], + "plugins": ["markdown"], + "overrides": [ + { + "files": ["**/demo/*.md"], + "processor": "markdown/markdown", + "rules": { + "no-console": "off" + } + } + ], + "rules": { + "comma-dangle": [2, "always-multiline"], + "no-var": "error", + "no-console": [2, { "allow": ["warn", "error"] }], + "object-shorthand": 2, + "no-unused-vars": [2, { "ignoreRestSiblings": true, "argsIgnorePattern": "^h$" }], + "no-undef": 2, + "camelcase": "off", + "no-extra-boolean-cast": "off", + "semi": ["error", "always"], + "vue/require-prop-types": "off", + "vue/require-default-prop": "off", + "vue/no-reserved-keys": "off", + "vue/comment-directive": "off", + "vue/prop-name-casing": "off", + "vue/max-attributes-per-line": [ + 2, + { + "singleline": 20, + "multiline": { + "max": 1, + "allowFirstLine": false + } + } + ] + }, + "globals": { + "h": true + } +} diff --git a/antdv-demo/.gitignore b/antdv-demo/.gitignore new file mode 100644 index 000000000..1b91ad56b --- /dev/null +++ b/antdv-demo/.gitignore @@ -0,0 +1,109 @@ +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +lerna-debug.log* + +# Diagnostic reports (https://nodejs.org/api/report.html) +report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json + +# Runtime data +pids +*.pid +*.seed +*.pid.lock + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage +*.lcov + +# nyc test coverage +.nyc_output + +# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# Bower dependency directory (https://bower.io/) +bower_components + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (https://nodejs.org/api/addons.html) +build/Release + +# Dependency directories +node_modules/ +jspm_packages/ + +# TypeScript v1 declaration files +typings/ + +# TypeScript cache +*.tsbuildinfo + +# Optional npm cache directory +.npm + +# Optional eslint cache +.eslintcache + +# Microbundle cache +.rpt2_cache/ +.rts2_cache_cjs/ +.rts2_cache_es/ +.rts2_cache_umd/ + +# Optional REPL history +.node_repl_history + +# Output of 'npm pack' +*.tgz + +# Yarn Integrity file +.yarn-integrity + +# dotenv environment variables file +.env +.env.test + +# parcel-bundler cache (https://parceljs.org/) +.cache + +# Next.js build output +.next + +# Nuxt.js build / generate output +.nuxt +dist + +# Gatsby files +.cache/ +# Comment in the public line in if your project uses Gatsby and *not* Next.js +# https://nextjs.org/blog/next-9-1#public-directory-support +# public + +# vuepress build output +.vuepress/dist + +# Serverless directories +.serverless/ + +# FuseBox cache +.fusebox/ + +# DynamoDB Local files +.dynamodb/ + +# TernJS port file +.tern-port + +site/dev.js +_site/ +package-lock.json +testDemo/ diff --git a/antdv-demo/.huskyrc b/antdv-demo/.huskyrc new file mode 100644 index 000000000..1a7c5875b --- /dev/null +++ b/antdv-demo/.huskyrc @@ -0,0 +1,7 @@ +{ + "hooks": { + "pre-commit": "pretty-quick --staged", + "pre-publish": "npm run lint", + "commit-msg": "commitlint -x @commitlint/config-conventional -e $GIT_PARAMS" + } +} diff --git a/antdv-demo/.prettierignore b/antdv-demo/.prettierignore new file mode 100644 index 000000000..6a0eec280 --- /dev/null +++ b/antdv-demo/.prettierignore @@ -0,0 +1,29 @@ +**/*.svg +package.json +lib/ +es/ +dist/ +_site/ +coverage/ +CNAME +LICENSE +yarn.lock +netlify.toml +yarn-error.log +*.sh +*.snap +.gitignore +.npmignore +.prettierignore +.DS_Store +.editorconfig +.eslintignore +**/*.yml +components/style/color/*.less +**/assets +.gitattributes +.stylelintrc +.vcmrc +.png +.npmrc.template +.huskyrc diff --git a/antdv-demo/.prettierrc b/antdv-demo/.prettierrc new file mode 100644 index 000000000..84d393d19 --- /dev/null +++ b/antdv-demo/.prettierrc @@ -0,0 +1,14 @@ +{ + "singleQuote": true, + "trailingComma": "all", + "printWidth": 100, + "proseWrap": "never", + "overrides": [ + { + "files": ".prettierrc", + "options": { + "parser": "json" + } + } + ] +} diff --git a/antdv-demo/.stylelintrc b/antdv-demo/.stylelintrc new file mode 100644 index 000000000..9d422fb7c --- /dev/null +++ b/antdv-demo/.stylelintrc @@ -0,0 +1,23 @@ +{ + "extends": ["stylelint-config-standard", "stylelint-config-prettier"], + "rules": { + "comment-empty-line-before": null, + "declaration-empty-line-before": null, + "function-comma-newline-after": null, + "function-name-case": null, + "function-parentheses-newline-inside": null, + "function-max-empty-lines": null, + "function-whitespace-after": null, + "indentation": null, + "number-leading-zero": null, + "number-no-trailing-zeros": null, + "rule-empty-line-before": null, + "selector-combinator-space-after": null, + "selector-list-comma-newline-after": null, + "selector-pseudo-element-colon-notation": null, + "unit-no-unknown": null, + "value-list-max-empty-lines": null, + "font-family-no-missing-generic-family-keyword": null, + "no-descending-specificity": null + } +} diff --git a/antdv-demo/.umirc.mock.js b/antdv-demo/.umirc.mock.js new file mode 100644 index 000000000..5174e0e9d --- /dev/null +++ b/antdv-demo/.umirc.mock.js @@ -0,0 +1,3 @@ +module.exports = { + ...require('./mock/user'), +}; diff --git a/antdv-demo/build.sh b/antdv-demo/build.sh new file mode 100644 index 000000000..2f07b2403 --- /dev/null +++ b/antdv-demo/build.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env bash +rm -rf dist +mkdir dist +./node_modules/.bin/webpack --config webpack.site.config.js +cp dist/index.html index.html diff --git a/antdv-demo/build/config.js b/antdv-demo/build/config.js new file mode 100644 index 000000000..e54a2e102 --- /dev/null +++ b/antdv-demo/build/config.js @@ -0,0 +1,5 @@ +module.exports = { + dev: { + componentName: 'form', // dev components + }, +}; diff --git a/antdv-demo/build/dev.js b/antdv-demo/build/dev.js new file mode 100644 index 000000000..d8f76f867 --- /dev/null +++ b/antdv-demo/build/dev.js @@ -0,0 +1,213 @@ +process.env.ENTRY_INDEX = 'dev'; + +const fs = require('fs'); +const path = require('path'); +const chokidar = require('chokidar'); +const importFresh = require('import-fresh'); +const replace = require('json-templater/string'); +const webpack = require('webpack'); +const WebpackDevServer = require('webpack-dev-server'); +const devWebpack = require('./webpack.dev.conf'); + +const configPath = path.join(__dirname, './config.js'); + +/** + * a-bc-d --> aBcD + * @param {string} s + */ +const camelize = s => s.replace(/-(\w)/g, ($, $1) => $1.toUpperCase()); + +/** + * radio-group --> radio + * @param {string} s + */ +const getUpper = s => s.replace(/(-[a-z]*)/g, ''); + +let { componentName } = require('./config').dev; + +const componentsInPrototype = ['Modal', 'message', 'notification']; + +const MAIN_TEMPLATE = `import 'babel-polyfill'; +import Vue from 'vue'; +import Vuex from 'vuex'; +import VueI18n from 'vue-i18n'; +import VueRouter from 'vue-router'; +import VueClipboard from 'vue-clipboard2'; +import Md from '../components/md'; +import Api from '../components/api'; +import demoBox from '../components/demoBox'; +import demoSort from '../components/demoSort'; +import demoContainer from '../components/demoContainer'; +import { message, notification } from 'ant-design-vue'; +{{importComponents}} +{{importStyles}} +import 'ant-design-vue/es/message/style'; +import 'ant-design-vue/es/notification/style'; +import Test from '../docs/{{name}}/demo/index.vue'; +import zhCN from '../theme/zh-CN'; +import enUS from '../theme/en-US'; +import './index.less'; + +Vue.use(Vuex); +Vue.use(VueClipboard); +Vue.use(VueRouter); +Vue.use(VueI18n); +Vue.component(Md.name, Md); +Vue.component(Api.name, Api); +Vue.component('demo-box', demoBox); +Vue.component('demo-sort', demoSort); +Vue.component('demo-container', demoContainer); + +Vue.prototype.$message = message; +Vue.prototype.$notification = notification; +Vue.prototype.$info = Modal.info; +Vue.prototype.$success = Modal.success; +Vue.prototype.$error = Modal.error; +Vue.prototype.$warning = Modal.warning; +Vue.prototype.$confirm = Modal.confirm; +Vue.prototype.$destroyAll = Modal.destroyAll; +Vue.prototype.$form = Form; + +Vue.use(Modal); +{{install}} + +const i18n = new VueI18n({ + locale: enUS.locale, + messages: { + [enUS.locale]: { message: enUS.messages }, + [zhCN.locale]: { message: zhCN.messages }, + }, +}); + +const router = new VueRouter({ + mode: 'history', + routes: [{ + path: '/test', + component: () => import('../testDemo/index.vue'), + }, { + path: '/*', component: Test + }], +}); + +const store = new Vuex.Store({ + state: { + username: 'zeka', + }, + mutations: { + update(state, payload) { + state.username = payload.username; + }, + }, +}); +new Vue({ + el: '#app', + i18n, + router, + store, +}); +`; + +const OUTPUT_PATH = path.join(__dirname, '../site/dev.js'); + +const generateEntry = components => + Object.keys(components) + .map(component => `import ${component} from 'ant-design-vue/es/${components[component]}';`) + .join('\n'); + +const generateStyles = components => + Object.keys(components) + .map(component => `import 'ant-design-vue/es/${components[component]}/style';`) + .join('\n'); + +const generateInstall = components => + Object.keys(components) + .map(component => `Vue.use(${component});`) + .join('\n'); + +const renderTemplate = name => { + const components = { + Tooltip: 'tooltip', // for DemoBox + Icon: 'icon', // Basic + Form: 'form', + Modal: 'modal', + }; + + const demoPaths = fs + .readdirSync(path.join(__dirname, `../docs/${name}/demo`)) + .map(p => `../docs/${name}/demo/${p}`); + const testPaths = fs + .readdirSync(path.join(__dirname, `../testDemo`)) + .map(p => `../testDemo/${p}`); + [...demoPaths, ...testPaths].forEach(demoPath => { + const demo = fs.readFileSync(path.join(__dirname, demoPath)).toString(); + + const componentsInDemo = demo.match(/a-(\w+(-\w+)*)/g) || []; + componentsInDemo.forEach(name => { + const dirName = name.replace(/^a-/, ''); + const componentName = camelize(name).replace(/^a/, ''); + const upperComponentDir = getUpper(dirName); + const upperComponentName = upperComponentDir.replace(/^[a-z]/, $ => $.toUpperCase()); + + const componentPath = path.join(__dirname, `../../components/${dirName}`); + if (fs.existsSync(componentPath)) { + if (componentsInPrototype.includes(componentName)) { + return; + } + components[componentName] = dirName; + } else if (fs.existsSync(path.join(__dirname, `../../components/${upperComponentDir}`))) { + components[upperComponentName] = upperComponentDir; + } + }); + }); + + const importComponents = generateEntry(components); + const importStyles = generateStyles(components); + const install = generateInstall(components); + const template = replace(MAIN_TEMPLATE, { + importComponents, + importStyles, + install, + name, + }); + fs.writeFileSync(OUTPUT_PATH, template); +}; + +function fsExistsSync(path) { + try { + fs.accessSync(path, fs.F_OK); + } catch (e) { + return false; + } + return true; +} + +if (!fsExistsSync(path.join(__dirname, '../testDemo/index.vue'))) { + if (!fsExistsSync(path.join(__dirname, '../testDemo'))) { + fs.mkdirSync(path.join(__dirname, '../testDemo')); + } + fs.writeFileSync(path.join(__dirname, '../testDemo/index.vue'), ``); +} + +let demoWatcher; + +chokidar.watch(configPath, { ignoreInitial: true }).on('change', async () => { + ({ componentName } = importFresh(configPath).dev); + + demoWatcher && (await demoWatcher.close()); + + demoWatcher = chokidar.watch(path.join(__dirname, `../docs/${componentName}/demo`)); + demoWatcher.on('change', () => { + renderTemplate(componentName); + }); + + renderTemplate(componentName); +}); + +renderTemplate(componentName); + +const compiler = webpack(devWebpack); + +const configuration = devWebpack.devServer; + +const server = new WebpackDevServer(compiler, configuration); +server.listen(configuration.port); diff --git a/antdv-demo/build/getBabelCommonConfig.js b/antdv-demo/build/getBabelCommonConfig.js new file mode 100644 index 000000000..6f392971a --- /dev/null +++ b/antdv-demo/build/getBabelCommonConfig.js @@ -0,0 +1,45 @@ +'use strict'; + +module.exports = function(modules) { + const plugins = [ + require.resolve('babel-plugin-transform-vue-jsx'), + require.resolve('babel-plugin-inline-import-data-uri'), + require.resolve('babel-plugin-transform-es3-member-expression-literals'), + require.resolve('babel-plugin-transform-es3-property-literals'), + require.resolve('babel-plugin-transform-object-assign'), + require.resolve('babel-plugin-transform-object-rest-spread'), + require.resolve('babel-plugin-transform-class-properties'), + ]; + plugins.push([ + require.resolve('babel-plugin-transform-runtime'), + { + polyfill: false, + }, + ]); + return { + presets: [ + [ + require.resolve('babel-preset-env'), + { + modules, + targets: { + browsers: [ + 'last 2 versions', + 'Firefox ESR', + '> 1%', + 'ie >= 9', + 'iOS >= 8', + 'Android >= 4', + ], + }, + }, + ], + ], + plugins, + env: { + test: { + plugins: [require.resolve('babel-plugin-istanbul')], + }, + }, + }; +}; diff --git a/antdv-demo/build/lessLoaderConfig.js b/antdv-demo/build/lessLoaderConfig.js new file mode 100644 index 000000000..6529ba420 --- /dev/null +++ b/antdv-demo/build/lessLoaderConfig.js @@ -0,0 +1,166 @@ +const MiniCssExtractPlugin = require('mini-css-extract-plugin'); +module.exports = function(env) { + const isDev = env === 'development'; + return { + test: /\.less$/, + oneOf: [ + /* config.module.rule('less').oneOf('vue-modules') */ + { + resourceQuery: /module/, + use: [ + isDev + ? { + loader: 'vue-style-loader', + options: { + sourceMap: isDev, + shadowMode: false, + }, + } + : MiniCssExtractPlugin.loader, + { + loader: 'css-loader', + options: { + sourceMap: isDev, + importLoaders: 2, + modules: { + localIdentName: '[name]_[local]_[hash:base64:5]', + }, + }, + }, + { + loader: 'postcss-loader', + options: { + sourceMap: isDev, + }, + }, + { + loader: 'less-loader', + options: { + lessOptions: { + sourceMap: isDev, + modifyVars: {}, + javascriptEnabled: true, + }, + }, + }, + ], + }, + /* config.module.rule('less').oneOf('vue') */ + { + resourceQuery: /\?vue/, + use: [ + isDev + ? { + loader: 'vue-style-loader', + options: { + sourceMap: isDev, + shadowMode: false, + }, + } + : MiniCssExtractPlugin.loader, + { + loader: 'css-loader', + options: { + sourceMap: isDev, + importLoaders: 2, + }, + }, + { + loader: 'postcss-loader', + options: { + sourceMap: isDev, + }, + }, + { + loader: 'less-loader', + options: { + lessOptions: { + sourceMap: isDev, + modifyVars: {}, + javascriptEnabled: true, + }, + }, + }, + ], + }, + /* config.module.rule('less').oneOf('normal-modules') */ + { + test: /\.module\.\w+$/, + use: [ + isDev + ? { + loader: 'vue-style-loader', + options: { + sourceMap: isDev, + shadowMode: false, + }, + } + : MiniCssExtractPlugin.loader, + { + loader: 'css-loader', + options: { + sourceMap: isDev, + importLoaders: 2, + modules: { + localIdentName: '[name]_[local]_[hash:base64:5]', + }, + }, + }, + { + loader: 'postcss-loader', + options: { + sourceMap: isDev, + }, + }, + { + loader: 'less-loader', + options: { + lessOptions: { + sourceMap: isDev, + modifyVars: {}, + javascriptEnabled: true, + }, + }, + }, + ], + }, + /* config.module.rule('less').oneOf('normal') */ + { + use: [ + isDev + ? { + loader: 'vue-style-loader', + options: { + sourceMap: isDev, + shadowMode: false, + }, + } + : MiniCssExtractPlugin.loader, + { + loader: 'css-loader', + options: { + sourceMap: isDev, + importLoaders: 2, + }, + }, + { + loader: 'postcss-loader', + options: { + sourceMap: isDev, + }, + }, + { + loader: 'less-loader', + options: { + lessOptions: { + sourceMap: isDev, + modifyVars: {}, + javascriptEnabled: true, + }, + }, + }, + ], + }, + ], + }; +}; diff --git a/antdv-demo/build/webpack.base.conf.js b/antdv-demo/build/webpack.base.conf.js new file mode 100644 index 000000000..c7417d03d --- /dev/null +++ b/antdv-demo/build/webpack.base.conf.js @@ -0,0 +1,226 @@ +const path = require('path'); +const webpack = require('webpack'); +const Prism = require('prismjs'); +require('prismjs/components/prism-jsx.min.js'); +require('prismjs/components/prism-bash.min.js'); +require('prismjs/components/prism-json.min.js'); +require('prismjs/components/prism-diff.min.js'); +require('prismjs/components/prism-less.min.js'); +const Token = require('markdown-it/lib/token'); +const HardSourceWebpackPlugin = require('hard-source-webpack-plugin'); +const cheerio = require('cheerio'); +const WebpackBar = require('webpackbar'); +const VueLoaderPlugin = require('vue-loader/lib/plugin'); +const getBabelCommonConfig = require('./getBabelCommonConfig'); +const babelConfig = getBabelCommonConfig(false); + +babelConfig.plugins.push(require.resolve('babel-plugin-syntax-dynamic-import')); + +const fetch = (str, tag, scoped) => { + const $ = cheerio.load(str, { + decodeEntities: false, + xmlMode: true, + }); + if (!tag) { + return str; + } + if (tag === 'style') { + return scoped + ? $(`${tag}[scoped]`).html() + : $(`${tag}`) + .not(`${tag}[scoped]`) + .html(); + } + return $(tag).html(); +}; + +/** + * `{{ }}` => `{{ }}` + * @param {string} str + * @return {string} + */ +const replaceDelimiters = function(str) { + return str.replace(/({{|}})/g, '$1'); +}; + +/** + * renderHighlight + * @param {string} str + * @param {string} lang + */ + +const renderHighlight = function(str, lang) { + if (!(lang && Prism.languages[lang])) { + return ''; + } + + try { + return replaceDelimiters(Prism.highlight(str, Prism.languages[lang], lang)); + } catch (err) {} +}; + +const md = require('markdown-it')('default', { + html: true, + breaks: true, + highlight: renderHighlight, +}).use(require('markdown-it-anchor'), { + level: 2, + slugify: string => + string + .trim() + .split(' ') + .join('-'), + permalink: true, + // renderPermalink: (slug, opts, state, permalink) => {}, + permalinkClass: 'anchor', + permalinkSymbol: '#', + permalinkBefore: false, +}); +// md.renderer.rules.fence = wrap(md.renderer.rules.fence) +const cnReg = new RegExp('<(cn)(?:[^<]|<)+', 'g'); +const usReg = new RegExp('<(us)(?:[^<]|<)+', 'g'); +md.core.ruler.push('update_template', function replace({ tokens }) { + let cn = ''; + let us = ''; + let template = ''; + let script = ''; + let style = ''; + let scopedStyle = ''; + let code = ''; + let sourceCode = ''; + tokens.forEach(token => { + if (token.type === 'html_block') { + if (token.content.match(cnReg)) { + cn = fetch(token.content, 'cn'); + token.content = ''; + } + if (token.content.match(usReg)) { + us = fetch(token.content, 'us'); + token.content = ''; + } + } + if (token.type === 'fence' && token.info === 'vue' && token.markup === '```') { + sourceCode = token.content; + code = '```html\n' + token.content + '```'; + template = fetch(token.content, 'template'); + script = fetch(token.content, 'script'); + style = fetch(token.content, 'style'); + scopedStyle = fetch(token.content, 'style', true); + token.content = ''; + token.type = 'html_block'; + } + }); + if (template) { + let jsfiddle = { + us, + cn, + sourceCode: Buffer.from(sourceCode).toString('base64'), + }; + jsfiddle = md.utils.escapeHtml(JSON.stringify(jsfiddle)); + const codeHtml = code ? md.render(code.replace(/@/g, '__at__')).replace(/__at__/g, '@') : ''; + const cnHtml = cn ? md.render(cn) : ''; + let newContent = ` + `; + newContent += script + ? ` + + ` + : ''; + newContent += style ? `` : ''; + newContent += scopedStyle ? `` : ''; + const t = new Token('html_block', '', 0); + t.content = newContent; + tokens.push(t); + } +}); +const vueLoaderOptions = { + loaders: { + js: [ + { + loader: 'babel-loader', + options: { + presets: ['env'], + plugins: ['transform-vue-jsx', 'transform-object-rest-spread'], + }, + }, + ], + }, +}; +module.exports = { + mode: 'production', + entry: { + index: [`./site/${process.env.ENTRY_INDEX || 'index'}.js`], + }, + module: { + rules: [ + { + test: /\.md$/, + use: [ + { + loader: 'vue-loader', + options: vueLoaderOptions, + }, + { + loader: 'vue-antd-md-loader', + options: Object.assign(md, { + wrapper: 'div', + raw: true, + }), + }, + ], + }, + { + test: /\.vue$/, + loader: 'vue-loader', + options: vueLoaderOptions, + }, + { + test: /\.(js|jsx)$/, + loader: 'babel-loader', + exclude: /node_modules/, + options: babelConfig, + }, + { + test: /\.(png|jpg|gif|svg)$/, + loader: 'file-loader', + options: { + name: '[name].[ext]?[hash]', + }, + }, + ], + }, + resolve: + process.env.NODE_ENV === 'development' + ? { + modules: ['node_modules', path.join(__dirname, '../node_modules')], + extensions: ['.js', '.jsx', '.vue', '.md'], + alias: { + vue$: 'vue/dist/vue.esm.js', + 'ant-design-vue$': path.join(__dirname, '../../components/index.js'), + 'ant-design-vue/es': path.join(__dirname, '../../components'), + 'ant-design-vue/lib': path.join(__dirname, '../../components'), + }, + } + : { + modules: ['node_modules'], + extensions: ['.js', '.jsx', '.vue', '.md'], + alias: { + vue$: 'vue/dist/vue.esm.js', + }, + }, + plugins: [ + new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/), + new VueLoaderPlugin(), + new WebpackBar(), + new HardSourceWebpackPlugin(), + ], +}; diff --git a/antdv-demo/build/webpack.dev.conf.js b/antdv-demo/build/webpack.dev.conf.js new file mode 100644 index 000000000..3f4b5ae2a --- /dev/null +++ b/antdv-demo/build/webpack.dev.conf.js @@ -0,0 +1,59 @@ +const path = require('path'); +const HtmlWebpackPlugin = require('html-webpack-plugin'); +const merge = require('webpack-merge'); +const baseWebpackConfig = require('./webpack.base.conf'); +const lessLoaderConfig = require('./lessLoaderConfig'); +const { createMockMiddleware } = require('umi-mock-middleware'); + +module.exports = merge(baseWebpackConfig, { + mode: 'development', + output: { + path: path.resolve(__dirname, '../dist'), + publicPath: '/', + filename: 'build.js', + }, + module: { + rules: [ + { + test: /\.css$/, + use: ['vue-style-loader', 'css-loader'], + }, + lessLoaderConfig('development'), + ], + }, + devServer: { + port: process.env.PORT || 3000, + host: '0.0.0.0', + historyApiFallback: { + rewrites: [{ from: /./, to: '/index.html' }], + }, + disableHostCheck: true, + hot: true, + open: true, + headers: { 'Access-Control-Allow-Origin': '*' }, + // 解析body,对接真实服务端环境需要注释掉 + before(app) { + // var bodyParser = require("body-parser"); + // app.use(bodyParser.json()); + if (process.env.MOCK !== 'none') { + app.use(createMockMiddleware()); + } + }, + proxy: { + '/api': { + target: 'http://localhost:3000', + }, + }, + }, + performance: { + hints: false, + }, + devtool: '#source-map', + plugins: [ + new HtmlWebpackPlugin({ + template: 'public/index.html', + filename: 'index.html', + inject: true, + }), + ], +}); diff --git a/antdv-demo/build/webpack.site.conf.js b/antdv-demo/build/webpack.site.conf.js new file mode 100644 index 000000000..7ced9e45b --- /dev/null +++ b/antdv-demo/build/webpack.site.conf.js @@ -0,0 +1,64 @@ +const path = require('path'); +const webpack = require('webpack'); +const MiniCssExtractPlugin = require('mini-css-extract-plugin'); +const TerserJSPlugin = require('terser-webpack-plugin'); +const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin'); + +const HtmlWebpackPlugin = require('html-webpack-plugin'); +const merge = require('webpack-merge'); +const baseWebpackConfig = require('./webpack.base.conf'); +let lessLoaderConfig = require('./lessLoaderConfig')('production'); + +module.exports = merge(baseWebpackConfig, { + output: { + path: path.resolve(__dirname, '../_site'), + publicPath: 'https://alicdn.antdv.com/v1/', + filename: '[name].[contenthash:8].js', + chunkFilename: '[contenthash:8].async.js', + }, + module: { + rules: [ + lessLoaderConfig, + { + test: /\.css$/, + use: [MiniCssExtractPlugin.loader, 'css-loader', 'postcss-loader'], + }, + ], + }, + optimization: { + splitChunks: { + cacheGroups: { + vendors: { + name: `chunk-vendors`, + test: /[\\/]node_modules[\\/]/, + priority: -10, + chunks: 'initial', + }, + common: { + name: `chunk-common`, + minChunks: 2, + priority: -20, + chunks: 'initial', + reuseExistingChunk: true, + }, + }, + }, + minimizer: [new TerserJSPlugin({}), new OptimizeCSSAssetsPlugin({})], + }, + plugins: [ + new webpack.DefinePlugin({ + 'process.env': { + NODE_ENV: '"production"', + }, + }), + new HtmlWebpackPlugin({ + template: './public/index.html', + inject: true, + production: true, + }), + new MiniCssExtractPlugin({ + filename: '[name].[contenthash:8].css', + chunkFilename: '[id].[contenthash:8].css', + }), + ], +}); diff --git a/antdv-demo/components/CarbonAds.vue b/antdv-demo/components/CarbonAds.vue new file mode 100644 index 000000000..b6e6a2840 --- /dev/null +++ b/antdv-demo/components/CarbonAds.vue @@ -0,0 +1,124 @@ + + diff --git a/antdv-demo/components/GoogleAds.vue b/antdv-demo/components/GoogleAds.vue new file mode 100644 index 000000000..170ec7688 --- /dev/null +++ b/antdv-demo/components/GoogleAds.vue @@ -0,0 +1,36 @@ + diff --git a/antdv-demo/components/GoogleAds1.vue b/antdv-demo/components/GoogleAds1.vue new file mode 100644 index 000000000..4d5438639 --- /dev/null +++ b/antdv-demo/components/GoogleAds1.vue @@ -0,0 +1,35 @@ + diff --git a/antdv-demo/components/GoogleAds2.vue b/antdv-demo/components/GoogleAds2.vue new file mode 100644 index 000000000..860157067 --- /dev/null +++ b/antdv-demo/components/GoogleAds2.vue @@ -0,0 +1,35 @@ + diff --git a/antdv-demo/components/GoogleAdsMin.vue b/antdv-demo/components/GoogleAdsMin.vue new file mode 100644 index 000000000..f691fe0b0 --- /dev/null +++ b/antdv-demo/components/GoogleAdsMin.vue @@ -0,0 +1,34 @@ + diff --git a/antdv-demo/components/GoogleAdsTop.vue b/antdv-demo/components/GoogleAdsTop.vue new file mode 100644 index 000000000..46bb509b7 --- /dev/null +++ b/antdv-demo/components/GoogleAdsTop.vue @@ -0,0 +1,35 @@ + diff --git a/antdv-demo/components/api.vue b/antdv-demo/components/api.vue new file mode 100644 index 000000000..62e8ec56c --- /dev/null +++ b/antdv-demo/components/api.vue @@ -0,0 +1,28 @@ + + diff --git a/antdv-demo/components/demoBox.vue b/antdv-demo/components/demoBox.vue new file mode 100644 index 000000000..523c988fd --- /dev/null +++ b/antdv-demo/components/demoBox.vue @@ -0,0 +1,230 @@ +