From b952a0d595625e04612364a9b57236236a4feade Mon Sep 17 00:00:00 2001 From: mirari Date: Fri, 8 Sep 2017 14:01:05 +0800 Subject: [PATCH] Fixed the problem that the URLs of fonts and images in the css files are incorrect when assetsPublicPath set to './' in production environment. Now the 'dist' directory can be visited by any URL root path at the same time. For example: http://192.168.1.101/project/, http://project.example.com/ --- build/utils.js | 5 ++++- config/index.js | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/build/utils.js b/build/utils.js index 5afbde6a..25a7f24e 100755 --- a/build/utils.js +++ b/build/utils.js @@ -32,7 +32,10 @@ exports.cssLoaders = options => { if (options.extract) { return ExtractTextPlugin.extract({ use: sourceLoader, - fallback: 'vue-style-loader' + fallback: 'vue-style-loader', + // Fixed the problem that the URLs of fonts and images in the css files are incorrect + // when assetsPublicPath set to './' in production environment + publicPath: '../../' }) } else { return ['vue-style-loader', sourceLoader].join('!') diff --git a/config/index.js b/config/index.js index c43ec8c6..106f7e09 100755 --- a/config/index.js +++ b/config/index.js @@ -9,7 +9,7 @@ module.exports = { index: path.resolve(__dirname, '../dist/index.html'), assetsRoot: path.resolve(__dirname, '../dist'), assetsSubDirectory: 'assets', - assetsPublicPath: '/', + assetsPublicPath: './', productionSourceMap: true, // Gzip off by default as many popular static hosts such as // Surge or Netlify already gzip all static assets for you.