Browse Source

explicitly search for node_modules, remove obsolete docs

master
salvatore-fxpig 2 years ago
parent
commit
be3ec90a82
  1. 2
      docs-src/docs/customise-client/api.md
  2. 3
      docs/customise-client/api.html
  3. 3
      docs/customise-client/api/index.html
  4. 43
      webpack.config.js

2
docs-src/docs/customise-client/api.md

@ -29,8 +29,6 @@ A useful reference may be the [customisation JSON file](https://github.com/nexts
* `googleAnalyticsKey` You can specify a Google Analytics key to enable (some) analytics functionality. More documentation to come.
* `serverAddress` Specify the address / prefix which the auspice client uses for API requests.
> For customisation code which uses [React](https://reactjs.org/) components, you must import these as `import React from "@libraries/react";` to ensure that the version of react is the same as what Auspice uses.
---
## Sidebar Theme

3
docs/customise-client/api.html

@ -76,9 +76,6 @@ A useful reference may be the <a href="https://github.com/nextstrain/nextstrain.
<li><code>googleAnalyticsKey</code> You can specify a Google Analytics key to enable (some) analytics functionality. More documentation to come.</li>
<li><code>serverAddress</code> Specify the address / prefix which the auspice client uses for API requests.</li>
</ul>
<blockquote>
<p>For customisation code which uses <a href="https://reactjs.org/">React</a> components, you must import these as <code>import React from &quot;@libraries/react&quot;;</code> to ensure that the version of react is the same as what Auspice uses.</p>
</blockquote>
<hr>
<h2><a class="anchor" aria-hidden="true" id="sidebar-theme"></a><a href="#sidebar-theme" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Sidebar Theme</h2>
<p>The appearence of the sidebar can be customised by specifing a theme in the config JSON used to build Auspice.

3
docs/customise-client/api/index.html

@ -76,9 +76,6 @@ A useful reference may be the <a href="https://github.com/nextstrain/nextstrain.
<li><code>googleAnalyticsKey</code> You can specify a Google Analytics key to enable (some) analytics functionality. More documentation to come.</li>
<li><code>serverAddress</code> Specify the address / prefix which the auspice client uses for API requests.</li>
</ul>
<blockquote>
<p>For customisation code which uses <a href="https://reactjs.org/">React</a> components, you must import these as <code>import React from &quot;@libraries/react&quot;;</code> to ensure that the version of react is the same as what Auspice uses.</p>
</blockquote>
<hr>
<h2><a class="anchor" aria-hidden="true" id="sidebar-theme"></a><a href="#sidebar-theme" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Sidebar Theme</h2>
<p>The appearence of the sidebar can be customised by specifing a theme in the config JSON used to build Auspice.

43
webpack.config.js

@ -17,18 +17,41 @@ const generateConfig = ({extensionPath, devMode=false, customOutputPath, analyze
/* which directories should be parsed by babel and other loaders? */
const directoriesToTransform = [path.join(__dirname, 'src')];
// Pins all react stuff, and uses hot loader's dom (can be used safely in production)
// Format is either "libName" or "libName:libPath"
const coreDeps = [
"react",
"react-hot-loader",
"react-dom:@hot-loader/react-dom",
"regenerator-runtime",
"core-js",
"styled-components"
];
// Actively searches for the "good" root starting from auspice dir and going backwards
// In 99.9% of practical cases these should all resolve wrt the node_modules in the root project,
// but if there are conflict they will preferentially resolve to auspice's node_modules
let baseDir = __dirname;
let foundNodeModules = false;
const resolvedCoreDeps = {};
while (!foundNodeModules) {
foundNodeModules = true;
for (const coreDep of coreDeps) {
const coreDepParts = coreDep.split(":");
if (!resolvedCoreDeps[coreDepParts[0] || coreDep]) {
const modulePath = path.join(baseDir, "node_modules", coreDepParts[1] || coreDep);
foundNodeModules = foundNodeModules && fs.existsSync(modulePath);
if (foundNodeModules) resolvedCoreDeps[coreDepParts[0] || coreDep] = modulePath;
}
}
baseDir = foundNodeModules ? baseDir : path.resolve(baseDir, "..");
}
/* webpack alias' used in code import / require statements */
const aliasesToResolve = {
"@extensions": path.join(__dirname, '.null'), /* must provide a default, else it won't compile */
"@auspice": path.join(__dirname, 'src'),
"@libraries": path.join(__dirname, 'node_modules'),
// Pins all react stuff to auspice dir, and uses hot loader's dom (can be used safely in production)
"react": path.join(__dirname, 'node_modules/react'), // eslint-disable-line quote-props
"react-hot-loader": path.join(__dirname, 'node_modules/react-hot-loader'),
'react-dom': path.join(__dirname, 'node_modules/@hot-loader/react-dom'),
'regenerator-runtime': path.join(__dirname, 'node_modules/regenerator-runtime'),
'core-js': path.join(__dirname, 'node_modules/core-js'),
'styled-components': path.join(__dirname, 'node_modules/styled-components')
...resolvedCoreDeps
};
let extensionData;
@ -86,9 +109,7 @@ const generateConfig = ({extensionPath, devMode=false, customOutputPath, analyze
plugins.push(new BundleAnalyzerPlugin());
}
const entry = devMode
? ["webpack-hot-middleware/client", "./src/index"]
: ["./src/index"];
const entry = devMode ? ["webpack-hot-middleware/client", "./src/index"] : ["./src/index"];
/* Where do we want the output to be saved?
* For development we use the (virtual) "devel" directory

Loading…
Cancel
Save