Skip to content

Commit

Permalink
Add environment variable for webpack dev HTTPS (#290)
Browse files Browse the repository at this point in the history
* Add environment variable for webpack dev HTTPS

* Fix error with protocol
  • Loading branch information
karlhorky authored and jchip committed Apr 22, 2017
1 parent 9605bf1 commit a5f3a7c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,16 @@ const webpack = require("webpack");
const archetype = require("electrode-archetype-react-app/config/archetype");
const webpackDevReporter = require("../util/webpack-dev-reporter");

const devProtocol = process.env.WEBPACK_DEV_HTTPS ? "https://" : "http://";

module.exports = function () {
const config = {
devServer: {
reporter: webpackDevReporter
reporter: webpackDevReporter,
https: Boolean(process.env.WEBPACK_DEV_HTTPS)
},
output: {
publicPath: `http://${archetype.webpack.devHostname}:${archetype.webpack.devPort}/js/`,
publicPath: `${devProtocol}${archetype.webpack.devHostname}:${archetype.webpack.devPort}/js/`,
filename: "[name].bundle.dev.js"
},
plugins: [
Expand Down
6 changes: 4 additions & 2 deletions packages/electrode-react-webapp/lib/react-webapp.js
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,8 @@ const setupOptions = (options) => {
htmlFile: Path.join(__dirname, "index.html"),
devServer: {
host: process.env.WEBPACK_HOST || "127.0.0.1",
port: process.env.WEBPACK_DEV_PORT || "2992"
port: process.env.WEBPACK_DEV_PORT || "2992",
https: Boolean(process.env.WEBPACK_DEV_HTTPS)
},
paths: {},
stats: "dist/server/stats.json",
Expand All @@ -254,7 +255,8 @@ const setupOptions = (options) => {

const pluginOptions = _.defaultsDeep({}, options, pluginOptionsDefaults);
const chunkSelector = resolveChunkSelector(pluginOptions);
const devBundleBase = `http://${pluginOptions.devServer.host}:${pluginOptions.devServer.port}/js/`;
const devProtocol = process.env.WEBPACK_DEV_HTTPS ? "https://" : "http://";
const devBundleBase = `${devProtocol}${pluginOptions.devServer.host}:${pluginOptions.devServer.port}/js/`; // eslint-disable-line max-len
const statsPath = getStatsPath(pluginOptions.stats, pluginOptions.buildArtifacts);

return Promise.try(() => loadAssetsFromStats(statsPath))
Expand Down

0 comments on commit a5f3a7c

Please sign in to comment.