当我跑npm run build
的时候,我面临着用相对路径进行正确构建的困难.解析assets资源 很容易,但我不知道如何配置两件事:
1/config/index.js
中的assetsPublicPath
// see http://vuejs-templates.github.io/webpack for documentation.
var path = require('path')
module.exports = {
build: {
env: require('./prod.env'),
index: path.resolve(__dirname, '../dist/index.html'),
assetsRoot: path.resolve(__dirname, '../dist'),
assetsSubDirectory: 'static',
assetsPublicPath: '/ONLY_ABSOLUTE_PATH_ARE_ALLOWED/',
productionSourceMap: true,
// Gzip off by default as many popular static hosts such as
// Surge or Netlify already gzip all static assets for you.
// Before setting to `true`, make sure to:
// npm install --save-dev compression-webpack-plugin
productionGzip: false,
productionGzipExtensions: ['js', 'css']
},
dev: {
env: require('./dev.env'),
port: 8080,
assetsSubDirectory: 'static',
assetsPublicPath: '/',
proxyTable: {},
// CSS Sourcemaps off by default because relative paths are "buggy"
// with this option, according to the CSS-Loader README
// (https://github.com/webpack/css-loader#sourcemaps)
// In our experience, they generally work as expected,
// just be aware of this issue when enabling this option.
cssSourceMap: false
}
}
2/vue-router
配置中的base
选项似乎也只接受绝对路径...
const router = new VueRouter({
mode: 'history',
base: '/ABSOLUTE_PATH_ONLY/',
routes: [
{ path: '/', redirect: '/fr/poster/home' },
{ path: '/:lang', redirect: '/:lang/poster/home' },
{
path: '/:lang/poster',
component: PosterLayout,
children: [
{
// UserProfile will be rendered inside User's <router-view>
// when /user/:id/profile is matched
name: 'home',
path: 'home',
component: Home
},
{
// UserPosts will be rendered inside User's <router-view>
// when /user/:id/posts is matched
name: 'themeCover',
path: ':theme',
component: ThemeCover
}
]
},
{
name: 'themeDetails',
path: '/:lang/theme/:theme',
component: ThemeDetails
}
]
})
"在future 的情况下,它是正确的,所以它是修改的URL"的情况下,它是正确的...
如果这个问题可以解决的话,有什么办法解决吗?