Skip to content

Commit

Permalink
Some comments
Browse files Browse the repository at this point in the history
  • Loading branch information
ivansg44 committed Nov 25, 2024
1 parent f04c02a commit a5f1463
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>DataHarmonizer</title>
<!--Ignore script 404 on dev server; script only used in prod-->
<!--Ignore script 404 on dev server; this external import used in prod-->
<script src="dist-schemas/schemas.js"></script>
</head>
<body>
Expand Down
13 changes: 13 additions & 0 deletions web/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ module.exports = (env, argv) => {
filename: 'scripts/[name].js',
},
externals: {
// Schemas lib external to this webpack build. Imported in html file.
schemas: 'schemas',
},
plugins: [
Expand Down Expand Up @@ -54,14 +55,25 @@ module.exports = (env, argv) => {
},
};

// Difficult to run two webpack instances on a single dev server (i.e., this
// file, and the other webpack file that builds schemas). So for dev servers,
// we will insert all schema content into the webpack build generated by this
// file, and this singular build serves the entirety of the application. This
// is fine, because the whole point of having a separate build for schema
// content was to reduce production build times when users are only editing
// schema files (and not the rest of the application), but the dev server
// already gets around this problem through hot loading.
if (argv.mode === 'development') {
config.devtool = 'eval-source-map';
// The schemas lib will come from a direct import of the javascript, instead
// of embedding an external lib into the html
config.resolve = {
alias: {
schemas: path.resolve(__dirname, 'schemas.js'),
},
};
delete config.externals;
// Need pdf SOPs that schema build previously supplied
config.plugins.push(
new CopyPlugin({
patterns: [
Expand All @@ -73,6 +85,7 @@ module.exports = (env, argv) => {
],
})
);
// False emits don't play nice with dev servers either
for (const rule of config.module.rules) {
if (rule.hasOwnProperty('generator')) {
delete rule.generator.filename;
Expand Down

0 comments on commit a5f1463

Please sign in to comment.