添加 gh-pages

This commit is contained in:
liaoxuezhi 2019-05-09 19:30:08 +08:00
parent 2ed5a31cc4
commit 2d4905eebf
4 changed files with 135 additions and 3 deletions

1
.gitignore vendored
View File

@ -13,6 +13,7 @@ node_modules
/dist
/lib
/public
/gh-pages
/.vscode
/output
/toolkit/amis-renderer

View File

@ -14,4 +14,5 @@ fis-conf.js
/__tests__
/__mocks__
/coverage
/publish.sh
/publish.sh
/gh-pages

View File

@ -6,7 +6,7 @@ import {AlertComponent, ToastComponent} from '../../src/components/index';
import {
mapTree
} from '../../src/utils/helper';
import { Router, Route, IndexRoute, browserHistory, Link, Redirect } from 'react-router';
import { Router, Route, IndexRoute, browserHistory, hashHistory, Link, Redirect } from 'react-router';
import makeSchemaRenderer from './SchemaRender';
@ -712,9 +712,14 @@ export class App extends React.PureComponent {
export default function entry({pathPrefix}) {
PathPrefix = pathPrefix || '/examples';
let history = browserHistory;
if (process.env.NODE_ENV === 'production') {
history = hashHistory;
}
return (
<Router history={ browserHistory }>
<Router history={ history }>
<Route component={App}>
<Redirect from={`${PathPrefix}/`} to={`${PathPrefix}/pages/simple`} />
{navigations2route(PathPrefix)}

View File

@ -5,6 +5,7 @@ const path = require('path');
const parserMarkdown = require('./build/md-parser');
fis.get('project.ignore').push(
'public/**',
'gh-pages/**',
'.*/**'
);
@ -225,4 +226,128 @@ if (fis.project.currentMedia() === 'publish') {
});
// publishEnv.unhook('node_modules');
publishEnv.hook('relative');
} else if (fis.project.currentMedia() === 'gh-pages') {
const ghPages = fis.media('gh-pages');
ghPages.match('/node_modules/(**)', {
release: '/n/$1'
});
ghPages.match('/examples/(**)', {
release: '/$1'
});
ghPages.match('/{examples,docs}/**', {
preprocessor: function(contents, file) {
if (!file.isText() || typeof contents !== 'string') {
return contents;
}
return contents.replace(/(\\?(?:'|"))\/api\/mock2?\//g, function(_, qutoa) {
return qutoa + 'https://houtai.baidu.com/api/mock2/';
});
}
})
ghPages.match('mock/**.{json,js,conf}', {
release: false
});
ghPages.match('::package', {
packager: fis.plugin('deps-pack', {
'pkg/npm.js': [
'/mod.js',
'node_modules/**.js',
'!monaco-editor/**',
'!flv.js/**',
'!hls.js/**',
'!amis/lib/editor/**',
'!froala-editor/**',
'!amis/lib/components/RichText.js',
'!jquery/**',
'!zrender/**',
'!echarts/**',
],
'pkg/rich-text.js': [
'amis/lib/components/RichText.js',
'froala-editor/**',
'jquery/**'
],
'pkg/echarts.js': [
'zrender/**',
'echarts/**'
],
'pkg/api-mock.js': [
'mock/*.ts'
],
'pkg/app.js': [
'/app.tsx',
'/app.tsx:deps'
],
'pkg/rest.js': [
'**.{js,jsx,ts,tsx}',
'!static/mod.js',
'!monaco-editor/**',
'!echarts/**',
'!flv.js/**',
'!hls.js/**',
'!froala-editor/**',
'!jquery/**',
'!amis/lib/components/RichText.js',
'!zrender/**',
'!echarts/**',
],
// css 打包
'pkg/style.css': [
'node_modules/*/**.css',
'*.scss',
'!/scss/*.scss',
'/scss/*.scss'
]
})
});
ghPages.match('*.{css,less,scss}', {
optimizer: fis.plugin('clean-css'),
useHash: true
});
ghPages.match('::image', {
useHash: true
});
ghPages.match('*.{js,ts,tsx}', {
optimizer: fis.plugin('uglify-js'),
useHash: true
});
ghPages.match('*.map', {
release: false,
url: 'null',
useHash: false
});
ghPages.match('{*.jsx,*.tsx,*.ts}', {
moduleId: function (m, path) {
return fis.util.md5('amis' + path);
},
parser: fis.plugin('typescript', {
sourceMap: false,
importHelpers: true
})
});
ghPages.match('*', {
domain: '/amis',
deploy: [
fis.plugin('skip-packed'),
fis.plugin('local-deliver', {
to: './gh-pages'
})
]
});
ghPages.match('{*.min.js,monaco-editor/**.js}', {
optimizer: null
});
ghPages.match('monaco-editor/**.js', {
useHash: false
});
}