Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ft/fix nx builds #9

Merged
merged 6 commits into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 4 additions & 10 deletions .github/workflows/pr-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,12 @@ jobs:
- name: Install
run: |
yarn
# yarn prepare:front

# - name: Format
# run: yarn format:check

- name: Lint
run: yarn lint

# - name: Test
# run: yarn test

- name: Test
run: yarn test --passWithNoTests

# TODO: fix storybook builds
# - name: Build
# run: yarn build
- name: Build
run: yarn build
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ testem.log
# System Files
.DS_Store
Thumbs.db
/libs/ui-kit/storybook-static/
/libs/ui-kit-vue/storybook-static/
apps/frontend-vue/.env
infrastructure/.env
.nx-cache
Expand All @@ -47,4 +47,4 @@ apps/api/src/generated

# Next.js
.next
out
out
1 change: 1 addition & 0 deletions .tailwind/tailwind.theme.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@ export const tailwindTheme = {
'primary-600': '#1C64F2',
'primary-700': '#1A56DB',
'primary-800': '#1E429F',
secondary: '#FFD04D',
},
}
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@
apps/

- frontend-vue - vue
- frontend-react - react
- frontend-next - react
- api - graphQL, postgress
- api-mongo - node, mongoDB

libs/

- ui-kit
- ui-kit-vue

infrastructure/

Expand Down
26 changes: 10 additions & 16 deletions apps/frontend-next/eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,21 @@ const compat = new FlatCompat({

module.exports = [
...compat.extends(
'plugin:@nx/react-typescript',
'next',
'next/core-web-vitals'
'plugin:@nx/react-typescript'
// 'next',
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cliffgor this was the issue

cc @danielotieno

// 'next/core-web-vitals'
),
...baseConfig,
{
files: ['**/*.ts', '**/*.tsx', '**/*.js', '**/*.jsx'],
rules: {
'@next/next/no-html-link-for-pages': [
'error',
'apps/frontend-next/pages',
],
'@typescript-eslint/no-require-imports': 'off',
'import/extensions': 'off',
'import/no-unresolved': 'off',
},
languageOptions: {
parserOptions: { project: ['apps/frontend-next/tsconfig.json'] },
},
},
{
files: ['**/*.ts', '**/*.tsx'],
rules: {},
},
{
files: ['**/*.js', '**/*.jsx'],
rules: {},
},
...compat.config({ env: { jest: true } }).map((config) => ({
...config,
Expand All @@ -38,5 +32,5 @@ module.exports = [
...config.rules,
},
})),
{ ignores: ['.next/**/*'] },
{ ignores: ['!**/*', '**/.next/*', '**/jest.config.ts'] },
]
3 changes: 3 additions & 0 deletions apps/frontend-next/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"name": "@nx-vite-infra/frontend-next"
}
2 changes: 1 addition & 1 deletion apps/frontend-next/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export function Index() {
<div className="container">
<div id="welcome">
<h1>
<span> Hello there, </span>
<span className="text-secondary"> Hello there, </span>
Welcome frontend-next 👋
</h1>
</div>
Expand Down
2 changes: 2 additions & 0 deletions apps/frontend-next/postcss.config.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
const { join } = require('path')
const baseConfig = require('../../.tailwind/postcss.config')

// Note: If you use library-specific PostCSS/Tailwind configuration then you should remove the `postcssConfig` build
// option from your application's configuration (i.e. project.json).
//
// See: https://nx.dev/guides/using-tailwind-css-in-react#step-4:-applying-configuration-to-libraries

module.exports = {
...baseConfig,
plugins: {
tailwindcss: {
config: join(__dirname, 'tailwind.config.js'),
Expand Down
15 changes: 15 additions & 0 deletions apps/frontend-next/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,27 @@
"projectType": "application",
"tags": [],
"targets": {
"build": {
"executor": "@nx/next:build",
"outputs": ["{options.outputPath}"],
"defaultConfiguration": "production",
"options": {
"outputPath": "dist/apps/frontend-next"
}
},
"test": {
"executor": "@nx/jest:jest",
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
"options": {
"jestConfig": "apps/frontend-next/jest.config.ts"
}
},
"lint": {
"executor": "@nrwl/linter:eslint",
"outputs": ["{options.outputFile}"],
"options": {
"lintFilePatterns": ["apps/frontend-next/**/*.{ts,js,tsx,jsx}"]
}
}
}
}
4 changes: 4 additions & 0 deletions apps/frontend-next/tailwind.config.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
const { createGlobPatternsForDependencies } = require('@nx/react/tailwind')
const { join } = require('path')

const baseConfig = require('../../.tailwind/tailwind.config')

/** @type {import('tailwindcss').Config} */
module.exports = {
content: [
join(
__dirname,
'{src,pages,components,app}/**/*!(*.stories|*.spec).{ts,tsx,html}'
// TODO: add ui-kit-react
),
...createGlobPatternsForDependencies(__dirname),
],
presets: [baseConfig],
theme: {
extend: {},
},
Expand Down
4 changes: 3 additions & 1 deletion apps/frontend-vue/eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ module.exports = [
vue: eslintPluginVue,
},
},
{ ignores: ['!**/*'] },
{
ignores: ['!**/*', '**/dist/*', '**/node_modules', '**/vite.config.ts'],
},
{
languageOptions: {
parser: vueEslintParser,
Expand Down
2 changes: 1 addition & 1 deletion apps/frontend-vue/package.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"name": "frontend-vue"
"name": "@nx-vite-infra/frontend-vue"
}
47 changes: 12 additions & 35 deletions apps/frontend-vue/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,44 +6,21 @@
"tags": [],
"targets": {
"build": {
"executor": "@nxext/vite:build",
"outputs": ["{options.outputPath}"],
"executor": "nx:run-commands",
"outputs": ["{workspaceRoot}/dist/apps/frontend-vue/"],
"defaultConfiguration": "production",
"options": {
"outputPath": "dist/apps/frontend-vue",
"baseHref": "/",
"configFile": "apps/frontend-vue/vite.config.ts",
"postcssConfig": "apps/frontend-vue/postcss.config.js"
"commands": [
"mkdir -p dist/apps/frontend-vue",
"cp -r apps/frontend-vue/dist/** dist/apps/frontend-vue/"
],
"parallel": false
},
"configurations": {
"production": {
"fileReplacements": [
{
"replace": "apps/frontend-vue/src/environments/environment.ts",
"with": "apps/frontend-vue/src/environments/environment.prod.ts"
}
]
"dependsOn": [
{
"target": "vite:build"
}
}
},
"serve": {
"executor": "@nxext/vite:dev",
"options": {
"outputPath": "dist/apps/frontend-vue",
"baseHref": "/",
"configFile": "apps/frontend-vue/vite.config.ts",
"postcssConfig": "apps/frontend-vue/postcss.config.js"
},
"configurations": {
"production": {
"fileReplacements": [
{
"replace": "apps/frontend-vue/src/environments/environment.ts",
"with": "apps/frontend-vue/src/environments/environment.prod.ts"
}
]
}
}
]
},
"lint": {
"executor": "@nrwl/linter:eslint",
Expand All @@ -53,7 +30,7 @@
}
},
"test": {
"executor": "@nxext/vitest:vitest",
"executor": "@nx/vite:test",
"options": {
"vitestConfig": "apps/frontend-vue/vitest.config.ts"
}
Expand Down
3 changes: 1 addition & 2 deletions apps/frontend-vue/src/components/Register.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<script setup lang="ts">
import { FormInput } from "@nx-vite-vue/ui-kit"
import CustomButton from "../../../../libs/ui-kit/src/lib/components/CustomButton/CustomButton.vue"
import { FormInput, CustomButton } from '@nx-vite-infra/ui-kit-vue'
</script>
<template>
<!-- component -->
Expand Down
8 changes: 4 additions & 4 deletions apps/frontend-vue/tailwind.config.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
/** @type {import('tailwindcss').Config} */

const { join } = require("path")
const baseConfig = require("../../.tailwind/tailwind.config")
const { join } = require('path')
const baseConfig = require('../../.tailwind/tailwind.config')

module.exports = {
content: [
join(__dirname, "./src/**/!(*.stories|*.spec).{ts,js,html,vue}"),
join(__dirname, './src/**/!(*.stories|*.spec).{ts,js,html,vue}'),
join(
__dirname,
"../../../libs/ui-kit/src/**/!(*.stories|*.spec).{ts,js,vue,html}"
'../../../libs/ui-kit-vue/src/**/!(*.stories|*.spec).{ts,js,vue,html}'
),
],
presets: [baseConfig],
Expand Down
3 changes: 2 additions & 1 deletion apps/frontend-vue/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin'

export default defineConfig({
plugins: [vue()],
plugins: [vue(), nxViteTsPaths()],
})
File renamed without changes.
29 changes: 29 additions & 0 deletions libs/ui-kit-vue/.storybook/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import type { StorybookConfig } from '@storybook/vue3-vite'

import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin'
import { mergeConfig } from 'vite'
import vue from '@vitejs/plugin-vue'

const config: StorybookConfig = {
stories: ['../src/**/*.@(mdx|stories.@(js|jsx|ts|tsx))'],
addons: [
'@storybook/addon-essentials',
'@storybook/addon-interactions',
'@storybook/addon-themes',
],
framework: {
name: '@storybook/vue3-vite',
options: {},
},

viteFinal: async (config) =>
mergeConfig(config, {
plugins: [vue(), nxViteTsPaths()],
}),
}

export default config

// To customize your Vite configuration you can use the viteFinal field.
// Check https://storybook.js.org/docs/react/builders/vite#configuration
// and https://nx.dev/recipes/storybook/custom-builder-configs
24 changes: 24 additions & 0 deletions libs/ui-kit-vue/.storybook/preview.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import '../../../.tailwind/tailwind.base.css'

import { withThemeByDataAttribute } from '@storybook/addon-themes'

export const parameters = {
actions: { argTypesRegex: '^on[A-Z].*' },
controls: {
matchers: {
color: /(background|color)$/i,
date: /Date$/,
},
},
}

export const decorators = [
withThemeByDataAttribute({
themes: {
light: 'light',
dark: 'dark',
},
defaultTheme: 'light',
attributeName: 'data-mode',
}),
]
19 changes: 19 additions & 0 deletions libs/ui-kit-vue/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# ui-kit-vue

This library was generated with [Nx](https://nx.dev).

## Running storybook

Run `nx storybook ui-kit-vue`

## Building storybook

Run `nx build ui-kit-vue`

## Running unit tests

Run `nx test ui-kit-vue` to execute the unit tests via [Jest](https://jestjs.io).

## Running lint

Run `nx lint ui-kit-vue` to execute the lint via [ESLint](https://eslint.org/).
Loading
Loading