docs: add netlify.toml and update site-dist to _site

pull/538/head
tangjinzhou 2019-02-23 12:12:44 +08:00
parent 89c3a56362
commit 5db345b248
10 changed files with 140 additions and 26 deletions

View File

@ -5,5 +5,5 @@ node_modules/
/components/test/* /components/test/*
es/ es/
lib/ lib/
site-dist/ _site/
dist/ dist/

2
.gitignore vendored
View File

@ -62,7 +62,7 @@ typings/
dist dist
lib lib
es es
site-dist _site
yarn.lock yarn.lock
package-lock.json package-lock.json
/coverage /coverage

View File

@ -5,5 +5,5 @@
package.json package.json
es/** es/**
lib/** lib/**
site-dist/** _site/**
dist/** dist/**

115
netlify.toml Normal file
View File

@ -0,0 +1,115 @@
[build]
publish = "_site"
command = "npm run site"
[context.production]
command = "echo build"
publish = "."
[[redirects]]
from = "/docs/resource/download"
to = "/docs/spec/download"
status = 301
force = false
[[redirects]]
from = "/docs/resource/download-cn"
to = "/docs/spec/download-cn"
status = 301
force = false
[[redirects]]
from = "/docs/resource/reference"
to = "/docs/spec/reference"
status = 301
force = false
[[redirects]]
from = "/docs/resource/reference-cn"
to = "/docs/spec/reference-cn"
status = 301
force = false
[[redirects]]
from = "/docs/spec/feature"
to = "/docs/spec/values"
status = 301
force = false
[[redirects]]
from = "/docs/spec/feature-cn"
to = "/docs/spec/values-cn"
status = 301
force = false
[[redirects]]
from = "/docs/pattern/advanced-search"
to = "/docs/spec/overview"
status = 301
force = false
[[redirects]]
from = "/docs/pattern/advanced-search-cn"
to = "/docs/spec/overview-cn"
status = 301
force = false
[[redirects]]
from = "/docs/pattern/complex-table"
to = "/docs/spec/overview"
status = 301
force = false
[[redirects]]
from = "/docs/pattern/complex-table-cn"
to = "/docs/spec/overview-cn"
status = 301
force = false
[[redirects]]
from = "/docs/pattern/form"
to = "/docs/spec/overview"
status = 301
force = false
[[redirects]]
from = "/docs/pattern/form-cn"
to = "/docs/spec/overview-cn"
status = 301
force = false
[[redirects]]
from = "/docs/pattern/list"
to = "/docs/spec/overview"
status = 301
force = false
[[redirects]]
from = "/docs/pattern/list-cn"
to = "/docs/spec/overview-cn"
status = 301
force = false
[[redirects]]
from = "/docs/pattern/navigation"
to = "/docs/spec/overview"
status = 301
force = false
[[redirects]]
from = "/docs/pattern/navigation-cn"
to = "/docs/spec/overview-cn"
status = 301
force = false
[[redirects]]
from = "/docs/pattern/table"
to = "/docs/spec/overview"
status = 301
force = false
[[redirects]]
from = "/docs/pattern/table-cn"
to = "/docs/spec/overview-cn"
status = 301
force = false

View File

@ -28,7 +28,7 @@
"dev": "cross-env NODE_ENV=development ENTRY_INDEX=dev ./node_modules/.bin/webpack-dev-server --open --hot --port 3001", "dev": "cross-env NODE_ENV=development ENTRY_INDEX=dev ./node_modules/.bin/webpack-dev-server --open --hot --port 3001",
"start": "cross-env NODE_ENV=development ./node_modules/.bin/webpack-dev-server --open --hot", "start": "cross-env NODE_ENV=development ./node_modules/.bin/webpack-dev-server --open --hot",
"test": "cross-env NODE_ENV=test jest --config .jest.js", "test": "cross-env NODE_ENV=test jest --config .jest.js",
"site": "node scripts/run.js site-dist", "site": "node scripts/run.js _site",
"copy": "node scripts/run.js copy-html", "copy": "node scripts/run.js copy-html",
"compile": "node antd-tools/cli/run.js compile", "compile": "node antd-tools/cli/run.js compile",
"pub": "node antd-tools/cli/run.js pub", "pub": "node antd-tools/cli/run.js pub",

View File

@ -9,15 +9,15 @@ if [[ $TRAVIS_BRANCH == "master" && $TRAVIS_PULL_REQUEST == "false" ]] && [[ $TR
echo "Starting to update gh-pages\n" echo "Starting to update gh-pages\n"
rm -rf site-dist rm -rf _site
mkdir site-dist mkdir _site
git config --global user.email "travis@travis-ci.org" git config --global user.email "travis@travis-ci.org"
git config --global user.name "Travis" git config --global user.name "Travis"
npm run site npm run site
cd site-dist cd _site
git init git init
git add -f . git add -f .
git commit -m "Travis build" git commit -m "Travis build"

View File

@ -12,7 +12,7 @@ const mkdirp = require('mkdirp');
const cwd = process.cwd(); const cwd = process.cwd();
function dist(done) { function dist(done) {
rimraf.sync(path.join(cwd, 'site-dist')); rimraf.sync(path.join(cwd, '_site'));
process.env.RUN_ENV = 'PRODUCTION'; process.env.RUN_ENV = 'PRODUCTION';
const webpackConfig = require(path.join(cwd, 'webpack.site.config.js')); const webpackConfig = require(path.join(cwd, 'webpack.site.config.js'));
webpack(webpackConfig, (err, stats) => { webpack(webpackConfig, (err, stats) => {
@ -53,30 +53,30 @@ function copyHtml() {
input: fs.createReadStream(path.join(cwd, 'site/demoRoutes.js')), input: fs.createReadStream(path.join(cwd, 'site/demoRoutes.js')),
}); });
fs.writeFileSync( fs.writeFileSync(
path.join(cwd, 'site-dist/404.html'), path.join(cwd, '_site/404.html'),
fs.readFileSync(path.join(cwd, 'site/404.html')), fs.readFileSync(path.join(cwd, 'site/404.html')),
); );
fs.writeFileSync( fs.writeFileSync(
path.join(cwd, 'site-dist/index-cn.html'), path.join(cwd, '_site/index-cn.html'),
fs.readFileSync(path.join(cwd, 'site-dist/index.html')), fs.readFileSync(path.join(cwd, '_site/index.html')),
); );
fs.writeFileSync(path.join(cwd, 'site-dist/CNAME'), 'vue.ant.design'); fs.writeFileSync(path.join(cwd, '_site/CNAME'), 'vue.ant.design');
rl.on('line', line => { rl.on('line', line => {
if (line.indexOf('path:') > -1) { if (line.indexOf('path:') > -1) {
const name = line.split("'")[1].split("'")[0]; const name = line.split("'")[1].split("'")[0];
console.log('create path:', name); console.log('create path:', name);
const toPaths = [ const toPaths = [
`site-dist/components/${name}`, `_site/components/${name}`,
// `site-dist/components/${name}-cn`, // `_site/components/${name}-cn`,
`site-dist/iframe/${name}`, `_site/iframe/${name}`,
// `site-dist/iframe/${name}-cn`, // `_site/iframe/${name}-cn`,
]; ];
toPaths.forEach(toPath => { toPaths.forEach(toPath => {
rimraf.sync(path.join(cwd, toPath)); rimraf.sync(path.join(cwd, toPath));
mkdirp(path.join(cwd, toPath), function() { mkdirp(path.join(cwd, toPath), function() {
fs.writeFileSync( fs.writeFileSync(
path.join(cwd, `${toPath}/index.html`), path.join(cwd, `${toPath}/index.html`),
fs.readFileSync(path.join(cwd, 'site-dist/index.html')), fs.readFileSync(path.join(cwd, '_site/index.html')),
); );
}); });
}); });
@ -92,16 +92,16 @@ function copyHtml() {
const paths = file.path.split('/'); const paths = file.path.split('/');
const name = paths[paths.length - 1].split('.')[0].toLowerCase(); const name = paths[paths.length - 1].split('.')[0].toLowerCase();
const toPaths = [ const toPaths = [
'site-dist/docs', '_site/docs',
'site-dist/docs/vue', '_site/docs/vue',
`site-dist/docs/vue/${name}`, `_site/docs/vue/${name}`,
`site-dist/docs/vue/${name}-cn`, `_site/docs/vue/${name}-cn`,
]; ];
toPaths.forEach(toPath => { toPaths.forEach(toPath => {
mkdirp(path.join(cwd, toPath), function() { mkdirp(path.join(cwd, toPath), function() {
fs.writeFileSync( fs.writeFileSync(
path.join(cwd, `${toPath}/index.html`), path.join(cwd, `${toPath}/index.html`),
fs.readFileSync(path.join(cwd, 'site-dist/index.html')), fs.readFileSync(path.join(cwd, '_site/index.html')),
); );
}); });
}); });
@ -110,7 +110,7 @@ function copyHtml() {
); );
} }
gulp.task('site-dist', done => { gulp.task('_site', done => {
dist(() => { dist(() => {
copyHtml(); copyHtml();
}); });

View File

@ -22,7 +22,6 @@ const ignoreFiles = [
'es/**', 'es/**',
'lib/**', 'lib/**',
'dist/**', 'dist/**',
'site-dist/**',
'**/**.snap', '**/**.snap',
'**/**.map', '**/**.map',
'**/components/style/color/**', '**/components/style/color/**',

View File

@ -7,7 +7,7 @@ const baseWebpackConfig = require('./webpack.base.config');
module.exports = merge(baseWebpackConfig, { module.exports = merge(baseWebpackConfig, {
output: { output: {
path: path.resolve(__dirname, './site-dist'), path: path.resolve(__dirname, './_site'),
publicPath: '/', publicPath: '/',
filename: '[name].[contenthash:8].js', filename: '[name].[contenthash:8].js',
chunkFilename: '[contenthash:8].async.js', chunkFilename: '[contenthash:8].async.js',