From 2ba6acab19ae7fb8de64ee7d866cb0a4cfe5b765 Mon Sep 17 00:00:00 2001 From: Angelina Filippova Date: Tue, 7 May 2019 17:05:23 +0000 Subject: [PATCH] Configure assets public path per env --- build/webpack.dev.conf.js | 6 ++++-- build/webpack.prod.conf.js | 2 +- config/dev.env.js | 3 ++- config/index.js | 4 ++-- config/prod.env.js | 3 ++- 5 files changed, 11 insertions(+), 7 deletions(-) diff --git a/build/webpack.dev.conf.js b/build/webpack.dev.conf.js index 5df16341..eed01df9 100644 --- a/build/webpack.dev.conf.js +++ b/build/webpack.dev.conf.js @@ -16,6 +16,8 @@ function resolve(dir) { const HOST = process.env.HOST const PORT = process.env.PORT && Number(process.env.PORT) +const devEnv = require('../config/dev.env') + const devWebpackConfig = merge(baseWebpackConfig, { mode: 'development', module: { @@ -39,7 +41,7 @@ const devWebpackConfig = merge(baseWebpackConfig, { overlay: config.dev.errorOverlay ? { warnings: false, errors: true } : false, - publicPath: config.dev.assetsPublicPath, + publicPath: devEnv.ASSETS_PUBLIC_PATH, proxy: config.dev.proxyTable, quiet: true, // necessary for FriendlyErrorsPlugin watchOptions: { @@ -59,7 +61,7 @@ const devWebpackConfig = merge(baseWebpackConfig, { favicon: resolve('favicon.ico'), title: 'Admin FE', templateParameters: { - BASE_URL: config.dev.assetsPublicPath + config.dev.assetsSubDirectory, + BASE_URL: devEnv.ASSETS_PUBLIC_PATH + config.dev.assetsSubDirectory, }, }), ] diff --git a/build/webpack.prod.conf.js b/build/webpack.prod.conf.js index 5e991636..b694ec2d 100644 --- a/build/webpack.prod.conf.js +++ b/build/webpack.prod.conf.js @@ -57,7 +57,7 @@ const webpackConfig = merge(baseWebpackConfig, { favicon: resolve('favicon.ico'), title: 'Admin FE', templateParameters: { - BASE_URL: config.build.assetsPublicPath + config.build.assetsSubDirectory, + BASE_URL: env.ASSETS_PUBLIC_PATH + config.build.assetsSubDirectory, }, minify: { removeComments: true, diff --git a/config/dev.env.js b/config/dev.env.js index f2b2a130..6704d298 100644 --- a/config/dev.env.js +++ b/config/dev.env.js @@ -1,4 +1,5 @@ module.exports = { NODE_ENV: '"development"', - ENV_CONFIG: '"dev"' + ENV_CONFIG: '"dev"', + ASSETS_PUBLIC_PATH: '/' } diff --git a/config/index.js b/config/index.js index 599e4a63..7043ee18 100644 --- a/config/index.js +++ b/config/index.js @@ -8,7 +8,7 @@ module.exports = { dev: { // Paths assetsSubDirectory: 'static', - assetsPublicPath: '/', + // assetsPublicPath: '', // To configure assetsPublicPath set ASSETS_PUBLIC_PATH in dev/prod.env.js proxyTable: {}, // Various Dev Server settings @@ -60,7 +60,7 @@ module.exports = { * then assetsPublicPath should be set to "/bar/". * In most cases please use '/' !!! */ - assetsPublicPath: '/', + // assetsPublicPath: '', // To configure assetsPublicPath set ASSETS_PUBLIC_PATH in dev/prod.env.js /** * Source Maps diff --git a/config/prod.env.js b/config/prod.env.js index bfcd6d27..e8a2016f 100644 --- a/config/prod.env.js +++ b/config/prod.env.js @@ -1,5 +1,6 @@ module.exports = { NODE_ENV: '"production"', ENV_CONFIG: '"prod"', - BASE_API: '"https://api-prod"' + BASE_API: '"https://api-prod"', + ASSETS_PUBLIC_PATH: '/pleroma/admin/' }