Skip to content

Commit

Permalink
Migrate NX & fix stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
lega0208 committed Feb 1, 2024
1 parent bf57b04 commit caefdb8
Show file tree
Hide file tree
Showing 47 changed files with 3,158 additions and 1,525 deletions.
5 changes: 1 addition & 4 deletions apps/api/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,7 @@
},
"lint": {
"executor": "@nx/eslint:lint",
"outputs": ["{options.outputFile}"],
"options": {
"lintFilePatterns": ["apps/api/**/*.ts"]
}
"outputs": ["{options.outputFile}"]
},
"test": {
"executor": "@nx/jest:jest",
Expand Down
8 changes: 3 additions & 5 deletions apps/db-cli/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
"compiler": "tsc",
"generateIndexHtml": false,
"runtimeChunk": false,
"target": "node"
"target": "node",
"webpackConfig": "apps/db-cli/webpack.config.js"
},
"configurations": {
"production": {
Expand Down Expand Up @@ -56,10 +57,7 @@
},
"lint": {
"executor": "@nx/eslint:lint",
"outputs": ["{options.outputFile}"],
"options": {
"lintFilePatterns": ["apps/db-cli/**/*.ts"]
}
"outputs": ["{options.outputFile}"]
},
"test": {
"executor": "@nx/jest:jest",
Expand Down
28 changes: 7 additions & 21 deletions apps/db-cli/webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,8 @@
const { join } = require('path');
const { merge } = require('webpack-merge');
const CopyPlugin = require('copy-webpack-plugin');
const { composePlugins, withNx } = require('@nx/webpack');

module.exports = (config, context) => {
return merge(config, {
devtool: 'eval-cheap-module-source-map',
optimization: {
nodeEnv: process.env.NODE_ENV || 'development',
},
plugins: [
new CopyPlugin({
patterns: [
{
from: 'apps/db-cli/src/assets/package.json',
to: join(config.output.path, 'package.json'),
},
],
}),
],
});
};
// Nx plugins for webpack.
module.exports = composePlugins(withNx(), (config) => {
// Note: This was added by an Nx migration. Webpack builds are required to have a corresponding Webpack config file.
// See: https://nx.dev/recipes/webpack/webpack-config-setup
return config;
});
8 changes: 3 additions & 5 deletions apps/db-updater/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
"runtimeChunk": false,
"optimization": false,
"externalDependencies": "all",
"inspect": false
"inspect": false,
"webpackConfig": "apps/db-updater/webpack.config.js"
},
"configurations": {
"production": {
Expand All @@ -45,10 +46,7 @@
},
"lint": {
"executor": "@nx/eslint:lint",
"outputs": ["{options.outputFile}"],
"options": {
"lintFilePatterns": ["apps/db-updater/**/*.ts"]
}
"outputs": ["{options.outputFile}"]
},
"test": {
"executor": "@nx/jest:jest",
Expand Down
28 changes: 7 additions & 21 deletions apps/db-updater/webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,8 @@
const { join } = require('path');
const { merge } = require('webpack-merge');
const CopyPlugin = require('copy-webpack-plugin');
const { composePlugins, withNx } = require('@nx/webpack');

module.exports = (config, context) => {
return merge(config, {
devtool: 'eval-cheap-module-source-map',
optimization: {
nodeEnv: process.env.NODE_ENV || 'development'
},
plugins: [
new CopyPlugin({
patterns: [
{
from: 'apps/db-updater/src/assets/package.json',
to: join(config.output.path, 'package.json'),
},
],
}),
],
});
};
// Nx plugins for webpack.
module.exports = composePlugins(withNx(), (config) => {
// Note: This was added by an Nx migration. Webpack builds are required to have a corresponding Webpack config file.
// See: https://nx.dev/recipes/webpack/webpack-config-setup
return config;
});
5 changes: 1 addition & 4 deletions apps/log-viewer/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,7 @@
},
"lint": {
"executor": "@nx/eslint:lint",
"outputs": ["{options.outputFile}"],
"options": {
"lintFilePatterns": ["apps/log-viewer/**/*.ts"]
}
"outputs": ["{options.outputFile}"]
}
}
}
12 changes: 9 additions & 3 deletions apps/log-viewer/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ import { defineConfig } from 'vite';
import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin';
console.log(process.cwd());
export default defineConfig({
root: __dirname,
build: {
outDir: '../../dist/apps/log-viewer',
reportCompressedSize: true,
commonjsOptions: {
transformMixedEsModules: true,
},
},
cacheDir: '../../node_modules/.vite/log-viewer',

server: {
Expand All @@ -17,9 +25,7 @@ export default defineConfig({
host: 'localhost',
},

plugins: [
nxViteTsPaths(),
],
plugins: [nxViteTsPaths()],

// Uncomment this if you are using workers.
// worker: {
Expand Down
5 changes: 1 addition & 4 deletions apps/upd-e2e/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,7 @@
},
"lint": {
"executor": "@nx/eslint:lint",
"outputs": ["{options.outputFile}"],
"options": {
"lintFilePatterns": ["apps/upd-e2e/**/*.{js,ts}"]
}
"outputs": ["{options.outputFile}"]
}
},
"tags": [],
Expand Down
5 changes: 1 addition & 4 deletions apps/upd/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,7 @@
}
},
"lint": {
"executor": "@nx/eslint:lint",
"options": {
"lintFilePatterns": ["apps/upd/src/**/*.ts", "apps/upd/src/**/*.html"]
}
"executor": "@nx/eslint:lint"
},
"test": {
"executor": "@nx/jest:jest",
Expand Down
25 changes: 16 additions & 9 deletions apps/upd/vite.config.mts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { replaceFiles } from '@nx/vite/plugins/rollup-replace-files.plugin';
import { resolve } from 'path';
import { defineConfig, splitVendorChunkPlugin, type AliasOptions } from 'vite';
import { angular } from './vite-plugin/plugin';
Expand All @@ -13,8 +14,9 @@ export default defineConfig(({ mode }) => {
const prod = mode === 'production';

return {
root: __dirname,
base: '/',
root: projectRoot,
// root: projectRoot,
mode,
esbuild: {
logLevel: 'info',
Expand All @@ -24,6 +26,7 @@ export default defineConfig(({ mode }) => {
color: true,
},
build: {
commonjsOptions: { transformMixedEsModules: true },
sourcemap: prod ? 'hidden' : 'inline',
outDir: resolve(workspaceRoot, 'dist/apps/upd'),
assetsDir: './',
Expand All @@ -36,13 +39,17 @@ export default defineConfig(({ mode }) => {
logLevel: 'info',
treeshake: prod,
cache: true,
plugins: !prod && [visualizer() as any],
external: prod && [
'core-js',
'html2canvas',
'canvg',
'dompurify',
],
plugins: prod
? [
replaceFiles([
{
replace: 'apps/upd/src/environments/environment.ts',
with: 'apps/upd/src/environments/environment.prod.ts',
},
]),
]
: [visualizer() as any],
external: prod && ['core-js', 'html2canvas', 'canvg', 'dompurify'],
},
minify: prod,
cssMinify: prod,
Expand All @@ -59,7 +66,7 @@ export default defineConfig(({ mode }) => {
server: {
proxy: {
'/api': `http://localhost:${process.env['PORT'] || 9000}`,
}
},
},
logLevel: 'info',
json: {
Expand Down
Loading

0 comments on commit caefdb8

Please sign in to comment.