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/*
es/
lib/
site-dist/
_site/
dist/

2
.gitignore vendored
View File

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

View File

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

View File

@ -189,7 +189,7 @@
padding-top: 8px;
}
// Hide additional padding between last child node and next parent node
// Hide additional padding between last child node and next parent node
&:last-child {
padding-bottom: 0;
}

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",
"start": "cross-env NODE_ENV=development ./node_modules/.bin/webpack-dev-server --open --hot",
"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",
"compile": "node antd-tools/cli/run.js compile",
"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"
rm -rf site-dist
mkdir site-dist
rm -rf _site
mkdir _site
git config --global user.email "travis@travis-ci.org"
git config --global user.name "Travis"
npm run site
cd site-dist
cd _site
git init
git add -f .
git commit -m "Travis build"

View File

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

View File

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

View File

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