nx/graph/client/webpack.config.js
Jason Jean 6882ad14e4
chore(repo): update nx to 20.1.0-beta.2 (#28813)
<!-- Please make sure you have read the submission guidelines before
posting an PR -->
<!--
https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr
-->

<!-- Please make sure that your commit message follows our format -->
<!-- Example: `fix(nx): must begin with lowercase` -->

<!-- If this is a particularly complex change or feature addition, you
can request a dedicated Nx release for this pull request branch. Mention
someone from the Nx team or the `@nrwl/nx-pipelines-reviewers` and they
will confirm if the PR warrants its own release for testing purposes,
and generate it for you if appropriate. -->

## Current Behavior
<!-- This is the behavior we have today -->

This repo uses Nx 20.0.7

## Expected Behavior
<!-- This is the behavior we should expect with the changes in this PR
-->

This repo uses nx 20.1.0-beta.0

## Related Issue(s)
<!-- Please link the issue being fixed so it gets closed when this is
merged. -->

Fixes #
2024-11-07 16:49:40 -05:00

159 lines
3.9 KiB
JavaScript

const { join } = require('node:path');
// nx-ignore-next-line
const { NxAppWebpackPlugin } = require('@nx/webpack/app-plugin');
// nx-ignore-next-line
const { NxReactWebpackPlugin } = require('@nx/react/webpack-plugin');
module.exports = {
output: {
path: join(__dirname, '../../build/apps/graph'),
},
devServer: {
port: getPort(process.env.NX_TASK_TARGET_CONFIGURATION),
historyApiFallback: {
disableDotRule: true,
},
},
resolve: {
alias: {
react: 'preact/compat',
'react-dom/test-utils': 'preact/test-utils',
'react-dom': 'preact/compat', // Must be below test-utils
'react/jsx-runtime': 'preact/jsx-runtime',
},
},
plugins: [
new NxAppWebpackPlugin({
index: './src/index.html',
compiler: 'babel',
main: './src/main.tsx',
tsConfig: './tsconfig.app.json',
styles: ['./src/styles.css'],
scripts: [],
assets: getAssets(process.env.NX_TASK_TARGET_CONFIGURATION),
webpackConfig: './webpack.config.js',
outputHashing: 'none',
deleteOutputPath: false,
}),
new NxReactWebpackPlugin({
svgr: false,
}),
],
};
function getPort(nxConfiguration) {
switch (nxConfiguration) {
case 'nx-console':
return 4202;
case 'release':
return 4203;
case 'watch':
return 4204;
case 'release-static':
return 4205;
case 'dev-e2e':
return 4206;
default: // dev
return 4201;
}
}
function getAssets(nxConfiguration) {
switch (nxConfiguration) {
case 'nx-console':
return [
'./src/favicon.ico',
{
input: './src/assets/project-graphs',
output: '/assets/project-graphs',
glob: 'e2e.json',
},
{
input: './src/assets/nx-console',
output: '/',
glob: 'environment.js',
},
];
case 'release':
return [
'./src/favicon.ico',
{
input: './src/assets/project-graphs',
output: '/assets/project-graphs',
glob: 'e2e.json',
},
{
input: './src/assets/task-graphs',
output: '/assets/task-graphs',
glob: 'e2e.json',
},
{
input: './src/assets/source-maps',
output: '/assets/source-maps',
glob: 'e2e.json',
},
{
input: './src/assets/release',
output: '/',
glob: 'environment.js',
},
];
case 'watch':
return [
'./src/favicon.ico',
{
input: './src/assets/watch',
output: '/',
glob: 'environment.js',
},
];
case 'release-static':
return [
'./src/favicon.ico',
{
input: './src/assets/project-graphs',
output: '/assets/project-graphs',
glob: 'e2e.json',
},
{
input: './src/assets/task-graphs',
output: '/assets/task-graphs',
glob: 'e2e.json',
},
{
input: './src/assets/release-static',
output: '/',
glob: 'environment.js',
},
];
case 'dev-e2e':
return [
'./src/favicon.ico',
'./src/assets/project-graphs/',
'./src/assets/task-graphs/',
'./src/assets/task-inputs/',
'./src/assets/source-maps/',
{
input: './src/assets/dev-e2e',
output: '/',
glob: 'environment.js',
},
];
default: // dev
return [
'./src/favicon.ico',
'./src/assets/project-graphs/',
'./src/assets/task-graphs/',
'./src/assets/generated-project-graphs/',
'./src/assets/generated-task-graphs/',
'./src/assets/generated-task-inputs/',
'./src/assets/generated-source-maps/',
{
input: './src/assets/dev',
output: '/',
glob: 'environment.js',
},
];
}
}