How do I use the style.css file in angular? [duplicate] - javascript

This question already has answers here:
angular-cli how to add global styles?
(14 answers)
Closed 11 months ago.
I wanted this file to be the global styling sheet. But I don't know how to make a component reference it. Angular set-up here
Here is my component:

You can easily create components using angular cli, run the below command in the terminal where your project is located.
Command : ng generate component component_name
You can also check out this link
angular-cli how to add global styles?

Related

Automatic import/export of React components [duplicate]

This question already has answers here:
Is it possible to import modules from all files in a directory, using a wildcard?
(14 answers)
Closed 22 days ago.
I have a "Components" component and a "components" folder.
I want all the components in the folder to be automatically imported into "Components" for reuse. "Components.Button"
It's real?
I found the answer. This can't be done by default, but there is a good npm package for babel https://www.npmjs.com/package/babel-plugin-wildcard

Creating app folder but getting TypeScript files instead of JavaScript [duplicate]

This question already has an answer here:
How to install Next.js Tailwind explicitly with .js?
(1 answer)
Closed 10 months ago.
I was following a tutorial, to set up and create an react.js + tailwindcss app, I (and the tutorial maker) used.
npx create-next-app -e with-tailwindcss [app name]
the files and all are created but instead of getting javascript files (index.js etc) I get it in typescript (index.tsx).
(his)
(mine)
I read the next.js documentation and it said that if I wanted a TypeScript file I should add the --TypeScript flag to the command, which I didn't, yet still got the TypeScript files.
I followed the video and I didn't make anything different from his, so I'm wondering what did I make wrong and how to fix it.
Sorry for using any wrong tags I really don't know what I should've used.
You did nothing wrong. The example with-tailwindcss was recently converted to TypeScript. You can read about the decision in the corresponding pull request

Why is a statically generated page unstyled when sent to the client? [duplicate]

This question already has answers here:
How to inline CSS in the head tag of a NextJS project?
(3 answers)
Closed 1 year ago.
When running the Next.js official boilerplate npx create-next-app and previewing it in the browser, I noticed the statically generated html document isn't styled:
I believe this could lead to FOUC problems. How can I make sure that the page is already styled when served to the client, as in the case of Next.js' official site:
Note: I just created a boilerplate project using npx create-next-app and did not modify any code. I am using Next.js v12.0.7 and React v17.0.2.
To get the response similar to Next.js' website, you need to inline critical CSS. This is (still) experimental in next#12.0.7 (and undocumented). To enable it modify your next.config.js:
module.exports = {
experimental: { optimizeCss: true }
}
You need to install critters (yarn add -D critters or npm i -D critters) for this to work. Also, you need to run production build (next build && next start) not a dev one like you're doing in that image you have shared.
Result:

Nextjs components can't access env.local variables [duplicate]

This question already has answers here:
NextJS environment variables aren't working
(2 answers)
Closed 1 year ago.
I'm building a movie recommendation app and I'm trying to fetch over an Url that is defined on my .env.local file, however it seems that none of my components can access environment variables, but index.js and _app.js can. Is there any solution?
Edit: I don't know if this matters, but both my "pages" and "components" directories are on the same folder alongside the .env.local file.
You must use the prefix NEXT_PUBLIC_ if you want to access env variables from the client. Please checkout the documentation for more info: https://nextjs.org/docs/basic-features/environment-variables#exposing-environment-variables-to-the-browser

How to make core client-side JS functions availabe in TS [duplicate]

This question already has answers here:
Typescript cannot find name window or document
(3 answers)
Closed 2 years ago.
I have a TS project that uses Node, express, and handlebars. I also have some client-side JS that it uses with no problem. (Clarification: not using react, angular, vue, or any other client-side framework at the moment.)
I was looking into moving the client-side JS into TS as well. My Hello World example tries to use alert (literally alert("Hello World");) but won't compile (error: error TS2304: Cannot find name 'alert'.). Should be a simple enough, I just need to discover the module to import into the file (or the dependency to add to my package.config) to make core client-side JavaScript function available.
I can't seem to find the reference for how to do this (outside of a wealth of library-specific examples in angular, react, etc.).
So what dependency and/or import am I looking for to expose core client-side JS functions and the like to my TS project?
Ah.
The "lib" property of my tsconfig only included es2017. Added DOM and that fixed it.

Categories