Configure assets public path per env

This commit is contained in:
Angelina Filippova 2019-05-07 17:05:23 +00:00 committed by feld
parent 75182336c7
commit 2ba6acab19
5 changed files with 11 additions and 7 deletions

View file

@ -16,6 +16,8 @@ function resolve(dir) {
const HOST = process.env.HOST const HOST = process.env.HOST
const PORT = process.env.PORT && Number(process.env.PORT) const PORT = process.env.PORT && Number(process.env.PORT)
const devEnv = require('../config/dev.env')
const devWebpackConfig = merge(baseWebpackConfig, { const devWebpackConfig = merge(baseWebpackConfig, {
mode: 'development', mode: 'development',
module: { module: {
@ -39,7 +41,7 @@ const devWebpackConfig = merge(baseWebpackConfig, {
overlay: config.dev.errorOverlay overlay: config.dev.errorOverlay
? { warnings: false, errors: true } ? { warnings: false, errors: true }
: false, : false,
publicPath: config.dev.assetsPublicPath, publicPath: devEnv.ASSETS_PUBLIC_PATH,
proxy: config.dev.proxyTable, proxy: config.dev.proxyTable,
quiet: true, // necessary for FriendlyErrorsPlugin quiet: true, // necessary for FriendlyErrorsPlugin
watchOptions: { watchOptions: {
@ -59,7 +61,7 @@ const devWebpackConfig = merge(baseWebpackConfig, {
favicon: resolve('favicon.ico'), favicon: resolve('favicon.ico'),
title: 'Admin FE', title: 'Admin FE',
templateParameters: { templateParameters: {
BASE_URL: config.dev.assetsPublicPath + config.dev.assetsSubDirectory, BASE_URL: devEnv.ASSETS_PUBLIC_PATH + config.dev.assetsSubDirectory,
}, },
}), }),
] ]

View file

@ -57,7 +57,7 @@ const webpackConfig = merge(baseWebpackConfig, {
favicon: resolve('favicon.ico'), favicon: resolve('favicon.ico'),
title: 'Admin FE', title: 'Admin FE',
templateParameters: { templateParameters: {
BASE_URL: config.build.assetsPublicPath + config.build.assetsSubDirectory, BASE_URL: env.ASSETS_PUBLIC_PATH + config.build.assetsSubDirectory,
}, },
minify: { minify: {
removeComments: true, removeComments: true,

View file

@ -1,4 +1,5 @@
module.exports = { module.exports = {
NODE_ENV: '"development"', NODE_ENV: '"development"',
ENV_CONFIG: '"dev"' ENV_CONFIG: '"dev"',
ASSETS_PUBLIC_PATH: '/'
} }

View file

@ -8,7 +8,7 @@ module.exports = {
dev: { dev: {
// Paths // Paths
assetsSubDirectory: 'static', assetsSubDirectory: 'static',
assetsPublicPath: '/', // assetsPublicPath: '', // To configure assetsPublicPath set ASSETS_PUBLIC_PATH in dev/prod.env.js
proxyTable: {}, proxyTable: {},
// Various Dev Server settings // Various Dev Server settings
@ -60,7 +60,7 @@ module.exports = {
* then assetsPublicPath should be set to "/bar/". * then assetsPublicPath should be set to "/bar/".
* In most cases please use '/' !!! * In most cases please use '/' !!!
*/ */
assetsPublicPath: '/', // assetsPublicPath: '', // To configure assetsPublicPath set ASSETS_PUBLIC_PATH in dev/prod.env.js
/** /**
* Source Maps * Source Maps

View file

@ -1,5 +1,6 @@
module.exports = { module.exports = {
NODE_ENV: '"production"', NODE_ENV: '"production"',
ENV_CONFIG: '"prod"', ENV_CONFIG: '"prod"',
BASE_API: '"https://api-prod"' BASE_API: '"https://api-prod"',
ASSETS_PUBLIC_PATH: '/pleroma/admin/'
} }