From d8b3f5fb9a6d394257cedd1fda3f86ff64f21e5b Mon Sep 17 00:00:00 2001 From: Akihiko Odaki Date: Tue, 15 May 2018 00:45:37 +0900 Subject: [PATCH] Limit environment variables to expose to webpack (#7480) --- config/webpack/configuration.js | 5 ++++- config/webpack/production.js | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/config/webpack/configuration.js b/config/webpack/configuration.js index c06570944..cf8c0c7e1 100644 --- a/config/webpack/configuration.js +++ b/config/webpack/configuration.js @@ -33,7 +33,10 @@ const output = { module.exports = { settings, themes, - env, + env: { + CDN_HOST: env.CDN_HOST, + NODE_ENV: env.NODE_ENV, + }, loadersDir, output, }; diff --git a/config/webpack/production.js b/config/webpack/production.js index e1c681232..a82330791 100644 --- a/config/webpack/production.js +++ b/config/webpack/production.js @@ -6,7 +6,7 @@ const CompressionPlugin = require('compression-webpack-plugin'); const sharedConfig = require('./shared.js'); const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin; const OfflinePlugin = require('offline-plugin'); -const { publicPath } = require('./configuration.js'); +const { env, publicPath } = require('./configuration.js'); const path = require('path'); let compressionAlgorithm; @@ -90,7 +90,7 @@ module.exports = merge(sharedConfig, { '**/*.woff', ], ServiceWorker: { - entry: `imports-loader?process.env=>${encodeURIComponent(JSON.stringify(process.env))}!${encodeURI(path.join(__dirname, '../../app/javascript/mastodon/service_worker/entry.js'))}`, + entry: `imports-loader?process.env=>${encodeURIComponent(JSON.stringify(env))}!${encodeURI(path.join(__dirname, '../../app/javascript/mastodon/service_worker/entry.js'))}`, cacheName: 'mastodon', output: '../assets/sw.js', publicPath: '/sw.js',