This commit is contained in:
Eugene Pankov
2021-07-25 14:38:14 +02:00
parent e11193b807
commit cabbc17581
12 changed files with 74 additions and 53 deletions

View File

@@ -1,3 +1,4 @@
require('dotenv').config()
const baseConfig = require('./webpack.config.base.js')
const fs = require('fs')
const path = require('path')
@@ -12,6 +13,11 @@ const htmlPluginOptions = {
const outputPath = path.join(__dirname, 'build')
const backendURL = process.env.BACKEND_URL
if (process.env.DEV && !backendURL) {
backendURL = 'http://localhost:8001'
}
if (!backendURL) {
throw new Error('BACKEND_URL env var is required')
}
@@ -45,7 +51,7 @@ module.exports = {
}),
{
apply: (compiler) => {
compiler.hooks.afterEmit.tap('AfterEmitPlugin', _ => {
compiler.hooks.afterEmit.tap('AfterEmitPlugin', () => {
fs.writeFileSync(path.join(outputPath, 'config.json'), JSON.stringify({
backendURL,
}))