Skip to content

Commit

Permalink
properly handle base
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Apr 5, 2018
1 parent 2a6fe42 commit b5c6e9e
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
node_modules
*.log
.temp
docs/.vuepress/dist
vuepress
TODOs.md
6 changes: 3 additions & 3 deletions docs/.vuepress/config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module.exports = {
data: {
title: 'VuePress'
}
base: '/vuepress/',
title: 'VuePress',
dest: 'vuepress'
}
2 changes: 0 additions & 2 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# VuePress

![logo](/logo.png)

> Minimalistic docs generator with Vue component based layout system
4 changes: 3 additions & 1 deletion docs/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

## `.vuepress/config.js`

### baseUrl
### base

### title

### head

Expand Down
4 changes: 4 additions & 0 deletions docs/kitchen/sink.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,7 @@ var vm = new Vue({

- Foo is {{ $page.frontmatter.foo }}
- Bar is {{ $page.frontmatter.bar }}

## Using Site Data

<img :src="`${$site.base}logo.png`" alt="logo">
3 changes: 2 additions & 1 deletion lib/app/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import metadataMixin from './metadataMixin'
// async components;
// 2. exports siteData
// 3. exports routes
import { routes } from './.temp/siteData'
import { routes, siteData } from './.temp/siteData'

Vue.use(Router)

Expand All @@ -27,6 +27,7 @@ routes.push({

export function createApp () {
const router = new Router({
base: siteData.base,
mode: 'history',
fallback: false,
routes
Expand Down
4 changes: 3 additions & 1 deletion lib/prepare.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ async function resolveOptions (sourceDir) {
outDir: siteConfig.dest
? path.resolve(siteConfig.dest)
: path.resolve(sourceDir, '.vuepress/dist'),
publicPath: siteConfig.baseUrl || '/',
publicPath: siteConfig.base || '/',
pageFiles: await globby(['**/*.md', '!.vuepress'], { cwd: sourceDir })
}

Expand Down Expand Up @@ -110,6 +110,8 @@ async function resolveOptions (sourceDir) {

// resolve site data
options.siteData = Object.assign({}, siteConfig.data, {
title: siteConfig.title,
base: siteConfig.base || '/',
pages: pagesData
})

Expand Down
2 changes: 1 addition & 1 deletion lib/webpack/baseConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ module.exports = function createBaseConfig ({
.output
.path(outDir)
.filename(isProd ? '_assets/js/[name].[chunkhash:8].js' : '_assets/js/[name].js')
.publicPath(publicPath)
.publicPath(isProd ? publicPath : '/')

config.resolve
.set('symlinks', true)
Expand Down

0 comments on commit b5c6e9e

Please sign in to comment.