-
Notifications
You must be signed in to change notification settings - Fork 13
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
[Feature] Explore upgrades offered by Angular v18 #2735
Comments
Solution suggested by ChatGPTTo configure styles and themes for an Angular app in a monorepo managed with Nx, enabling reuse across multiple projects, you can follow these steps: 1. Create a Shared Styles LibraryFirst, create a shared library within the monorepo that will contain the styles and themes. This library can then be imported by any Angular project in the monorepo. nx generate @nrwl/angular:library shared-styles --style=scss This will generate a library named 2. Add Global Styles and Themes to the Shared LibraryIn the
$primary-color: #3498db;
$secondary-color: #2ecc71;
$font-family: 'Roboto', sans-serif;
@mixin theme {
body {
font-family: $font-family;
background-color: $primary-color;
color: $secondary-color;
}
} 3. Export Styles and ThemesEnsure that the styles and themes are exported so that other projects can import them. Modify the
export * from './lib/themes.scss'; 4. Import Shared Styles in Angular ProjectsIn your Angular projects, import the shared styles and themes. Open the
@use 'libs/shared-styles/src/lib/themes.scss' as *;
@include theme; 5. Configure Angular.jsonEnsure that the Angular project is aware of the shared library. Modify the {
"projects": {
"your-angular-app": {
"architect": {
"build": {
"options": {
"styles": [
"apps/your-angular-app/src/styles.scss",
"libs/shared-styles/src/lib/themes.scss"
]
}
}
}
}
}
} 6. Use Shared Styles in ComponentsTo use the shared styles in Angular components, you can import the SCSS files directly into the component styles.
@use 'libs/shared-styles/src/lib/themes.scss' as *;
@include theme; By following these steps, you will have a centralized shared styles and themes library that can be reused across multiple projects in your Nx monorepo. This approach helps maintain consistency and reduces duplication of styles and themes across projects. |
Solution suggested by ChatGPT (using Tailwind CSS)To integrate Tailwind CSS into your Angular app within an Nx monorepo and share styles and themes across multiple projects, follow these updated steps: 1. Install Tailwind CSSFirst, install Tailwind CSS and its dependencies in your workspace: npm install -D tailwindcss postcss autoprefixer Initialize Tailwind CSS configuration: npx tailwindcss init 2. Create a Shared Styles LibraryCreate a shared library to contain your Tailwind CSS configuration and custom styles. nx generate @nrwl/angular:library shared-styles 3. Configure Tailwind CSSCreate a
module.exports = {
content: [
'./src/**/*.{html,ts}',
'../../apps/**/src/**/*.{html,ts}', // Ensure it includes all Angular apps in your monorepo
],
theme: {
extend: {
colors: {
primary: '#3498db',
secondary: '#2ecc71',
},
fontFamily: {
sans: ['Roboto', 'sans-serif'],
},
},
},
plugins: [],
}; 4. Create Global StylesCreate a global CSS file in the
@tailwind base;
@tailwind components;
@tailwind utilities;
/* Custom styles can be added here */ 5. Configure PostCSSCreate a
module.exports = {
plugins: {
tailwindcss: { config: './tailwind.config.js' },
autoprefixer: {},
},
}; 6. Import Shared Styles in Angular ProjectsIn your Angular projects, import the shared styles. Open the
@import 'libs/shared-styles/src/lib/global-styles.css'; 7. Update Angular.jsonEnsure that the Angular project is configured to use PostCSS. Modify the {
"projects": {
"your-angular-app": {
"architect": {
"build": {
"options": {
"styles": [
"apps/your-angular-app/src/styles.css"
],
"stylePreprocessorOptions": {
"includePaths": [
"libs/shared-styles/src/lib"
]
},
"postcssOptions": {
"config": "libs/shared-styles/postcss.config.js"
}
}
}
}
}
}
} 8. Use Tailwind CSS in ComponentsYou can now use Tailwind CSS classes in your Angular components.
<div class="bg-primary text-secondary font-sans">
Hello, Tailwind CSS!
</div> 9. Update NX Workspace ConfigurationEnsure that the shared library is correctly set up in the Nx workspace. Check the By following these steps, you will have Tailwind CSS integrated into your Angular app within an Nx monorepo, with a shared styles library that can be reused across multiple projects. This approach ensures consistency and maintainability for styles and themes across your projects. |
The monorepo has been updated to Angular v18. The exploration of Tailwind and the use of esbuild will be done in different tickets. |
What product(s) is this feature for?
Agora, MODEL-AD, OpenChallenges
Description
The existing web apps in the monorepo use Angular v17, while Angular v18 has since been released. The new version includes improvements to SSR and support for esbuild as a replacement for webpack, promising faster build tasks.
Here are some observations made when initially generating the MODEL-AD app with Angular v18:
To explore transitioning to Angular v18, we could create an Angular v18 app and investigate the best way to style it. Ideally, this approach would allow styles and themes to be reused across projects.
cc @hallieswan @sagely1 @rrchai @vpchung
Anything else?
No response
Code of Conduct
The text was updated successfully, but these errors were encountered: