Skip to content

Commit

Permalink
Optionally build webpack that set's up runtime-config loading
Browse files Browse the repository at this point in the history
  • Loading branch information
soapy1 committed Dec 11, 2024
1 parent 17fc6ce commit 9bb3278
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
6 changes: 4 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ COPY . ./
RUN --mount=type=cache,target=/root/.yarn YARN_CACHE_FOLDER=/root/.yarn \
yarn install --immutable && \
yarn run build && \
yarn run webpack:prod bundle
STANDALONE=1 yarn run webpack:prod bundle

# ---------------------------------------------------------------------------------
# for production
Expand All @@ -27,9 +27,11 @@ COPY --from=build /usr/src/app/dist /usr/src/conda-store-ui/dist

RUN cd app && npm install

ENV NODE_ENV=production

EXPOSE 8000

CMD ["NODE_ENV=production", "node", "app/serve.js"]
CMD ["node", "app/serve.js"]

# ---------------------------------------------------------------------------------
# for dev
Expand Down
4 changes: 3 additions & 1 deletion src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
<head>
<meta charset="utf-8" />
<title><%= htmlWebpackPlugin.options.title %></title>
<script src="runtime-config.js"></script>
<% if (needsRuntimeConfig) { %>
<script src="runtime-config.js"></script>
<% } %>
</head>
<body>
</body>
Expand Down
4 changes: 4 additions & 0 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const packageJson = require('./package.json');

const isProd = process.env.NODE_ENV === "production";
const ASSET_PATH = isProd ? "" : "/";
const needsRuntimeConfig = process.env.STANDALONE || false ;
const version = packageJson.version;

// Calculate hash based on content, will be used when generating production
Expand Down Expand Up @@ -94,6 +95,9 @@ module.exports = {
new HtmlWebpackPlugin({
title: "conda-store",
template: "src/index.html",
templateParameters: {
needsRuntimeConfig: needsRuntimeConfig
}
}),
new HtmlWebpackPlugin({
filename: "memory-router-test.html",
Expand Down

0 comments on commit 9bb3278

Please sign in to comment.