From 1e74c9952cf0721b723a7b536318be21d1ca7c75 Mon Sep 17 00:00:00 2001 From: Evan You Date: Sat, 7 Apr 2018 15:18:31 -0400 Subject: [PATCH] fix deployment for github pages --- docs/.vuepress/config.js | 9 ++++++++- lib/prepare.js | 5 ++++- lib/webpack/baseConfig.js | 12 ++++++------ package.json | 3 ++- scripts/deploy-gh.sh | 5 +++++ 5 files changed, 25 insertions(+), 9 deletions(-) create mode 100644 scripts/deploy-gh.sh diff --git a/docs/.vuepress/config.js b/docs/.vuepress/config.js index 30b6495e..e905867f 100644 --- a/docs/.vuepress/config.js +++ b/docs/.vuepress/config.js @@ -1,5 +1,12 @@ module.exports = { title: 'VuePress', dest: 'vuepress', - description: 'Minimalistic docs generator with Vue component based layout system' + description: 'Minimalistic docs generator with Vue component based layout system', +} + +// set base URL if building for github +if (process.env.GH) { + Object.assign(module.exports, { + base: '/vuepress/' + }) } diff --git a/lib/prepare.js b/lib/prepare.js index 427b854e..c9553712 100644 --- a/lib/prepare.js +++ b/lib/prepare.js @@ -61,7 +61,10 @@ async function resolveOptions (sourceDir) { ? path.resolve(siteConfig.dest) : path.resolve(sourceDir, '.vuepress/dist'), publicPath: siteConfig.base || '/', - pageFiles: await globby(['**/*.md', '!.vuepress'], { cwd: sourceDir }) + pageFiles: await globby(['**/*.md', '!.vuepress'], { cwd: sourceDir }), + pagesData: null, + themePath: null, + notFoundPath: null } // resolve theme diff --git a/lib/webpack/baseConfig.js b/lib/webpack/baseConfig.js index 037888da..4cfda536 100644 --- a/lib/webpack/baseConfig.js +++ b/lib/webpack/baseConfig.js @@ -22,7 +22,7 @@ module.exports = function createBaseConfig ({ .set('mode', isProd && !debug ? 'production' : 'development') .output .path(outDir) - .filename(isProd ? '_assets/js/[name].[chunkhash:8].js' : '_assets/js/[name].js') + .filename(isProd ? 'assets/js/[name].[chunkhash:8].js' : 'assets/js/[name].js') .publicPath(isProd ? publicPath : '/') if (debug) { @@ -99,7 +99,7 @@ module.exports = function createBaseConfig ({ .loader('url-loader') .options({ limit: inlineLimit, - name: `_assets/img/[name].[hash:8].[ext]` + name: `assets/img/[name].[hash:8].[ext]` }) // do not base64-inline SVGs. @@ -110,7 +110,7 @@ module.exports = function createBaseConfig ({ .use('file-loader') .loader('file-loader') .options({ - name: `_assets/img/[name].[hash:8].[ext]` + name: `assets/img/[name].[hash:8].[ext]` }) config.module @@ -120,7 +120,7 @@ module.exports = function createBaseConfig ({ .loader('url-loader') .options({ limit: inlineLimit, - name: `_assets/media/[name].[hash:8].[ext]` + name: `assets/media/[name].[hash:8].[ext]` }) config.module @@ -130,7 +130,7 @@ module.exports = function createBaseConfig ({ .loader('url-loader') .options({ limit: inlineLimit, - name: `_assets/fonts/[name].[hash:8].[ext]` + name: `assets/fonts/[name].[hash:8].[ext]` }) function createCSSRule (lang, test, loader, options) { @@ -180,7 +180,7 @@ module.exports = function createBaseConfig ({ config .plugin('extract-css') .use(CSSExtractPlugin, [{ - filename: '_assets/css/styles.[chunkhash:8].css' + filename: 'assets/css/styles.[chunkhash:8].css' }]) // ensure all css are extracted together. diff --git a/package.json b/package.json index 4f59936d..9abf9786 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,8 @@ "scripts": { "dev": "node bin/vuepress dev docs", "build": "node bin/vuepress build docs", - "lint": "eslint bin lib test" + "lint": "eslint bin lib test", + "deploy-gh": "GH=1 yarn build && bash scripts/deploy-gh.sh" }, "repository": { "type": "git", diff --git a/scripts/deploy-gh.sh b/scripts/deploy-gh.sh new file mode 100644 index 00000000..d0e29841 --- /dev/null +++ b/scripts/deploy-gh.sh @@ -0,0 +1,5 @@ +cd vuepress +git init +git add -A +git commit -m 'deploy' +git push -f git@github.com:vuejs/vuepress.git master:gh-pages -- GitLab