Unverified Commit 9cbc4d88 authored by PapatMayuri's avatar PapatMayuri Committed by GitHub

Updated the example of with-styled-jsx-plugins to utilize the App Router (#70663)

This PR updates the with-styled-jsx-plugins example for using the App
Router.
Here are the changes that have been made:

- I renamed the "pages" folder and moved it to the "app" folder.
- Added the layout.TSX file as part of the App Router.
- Updated the package.json file.

CC: @samcx

---------
Co-authored-by: 's avatarqed42 <qed42@Janhvis-Macbook-Pro.local>
Co-authored-by: 's avatarSam Ko <sam@vercel.com>
parent bdca519c
{
"presets": [
[
"next/babel",
{
"styled-jsx": {
"plugins": ["styled-jsx-plugin-postcss"]
}
}
]
]
}
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
# dependencies
/node_modules
/.pnp
.pnp.js
.yarn/install-state.gz
# testing
/coverage
# next.js
/.next/
/out/
# production
/build
# misc
.DS_Store
*.pem
# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# local env files
.env*.local
# vercel
.vercel
# typescript
*.tsbuildinfo
next-env.d.ts
# With styled-jsx plugins
Next.js ships with [styled-jsx](https://github.com/vercel/styled-jsx) allowing you
to write scope styled components with full css support. This is important for
the modularity and code size of your bundles and also for the learning curve of the framework. If you know css you can write styled-jsx right away.
This example shows how to configure styled-jsx to use external plugins to modify the output. Using this you can use PostCSS, SASS (SCSS), LESS, or any other pre-processor with styled-jsx. You can define plugins in `.babelrc`. In this case PostCSS was used as an example. PostCSS plugins are defined in `package.json`.
More details about how plugins work can be found in the [styled-jsx readme](https://github.com/vercel/styled-jsx#css-preprocessing-via-plugins)
## Deploy your own
Deploy the example using [Vercel](https://vercel.com?utm_source=github&utm_medium=readme&utm_campaign=next-example):
[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/clone?repository-url=https://github.com/vercel/next.js/tree/canary/examples/with-styled-jsx-plugins&project-name=with-styled-jsx-plugins&repository-name=with-styled-jsx-plugins)
## How to use
Execute [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app) with [npm](https://docs.npmjs.com/cli/init), [Yarn](https://yarnpkg.com/lang/en/docs/cli/create/), or [pnpm](https://pnpm.io) to bootstrap the example:
```bash
npx create-next-app --example with-styled-jsx-plugins with-styled-jsx-plugins-app
```
```bash
yarn create next-app --example with-styled-jsx-plugins with-styled-jsx-plugins-app
```
```bash
pnpm create next-app --example with-styled-jsx-plugins with-styled-jsx-plugins-app
```
Deploy it to the cloud with [Vercel](https://vercel.com/new?utm_source=github&utm_medium=readme&utm_campaign=next-example) ([Documentation](https://nextjs.org/docs/deployment)).
/// <reference types="next" />
/// <reference types="next/image-types/global" />
// NOTE: This file should not be edited
// see https://nextjs.org/docs/pages/api-reference/config/typescript for more information.
{
"private": true,
"scripts": {
"dev": "next",
"build": "next build",
"start": "next start"
},
"dependencies": {
"lost": "^9.0.1",
"next": "latest",
"postcss": "^8.4.19",
"postcss-nested": "^6.0.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"styled-jsx-plugin-postcss": "^4.0.1"
},
"postcss": {
"plugins": {
"lost": {},
"postcss-nested": {}
}
},
"devDependencies": {
"@types/node": "^18.11.9",
"@types/react": "^18.0.25",
"@types/react-dom": "^18.0.9",
"typescript": "^4.9.3"
}
}
export default function Home() {
return (
<div className="hello">
<p>Hello World</p>
<style jsx>{`
.hello {
font:
15px Helvetica,
Arial,
sans-serif;
background: #eee;
padding: 100px;
text-align: center;
transition: 100ms ease-in background;
lost-column: 1/3;
&:hover {
color: red;
}
}
.hello:hover {
background: #ccc;
}
`}</style>
</div>
);
}
{
"compilerOptions": {
"target": "es5",
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"strict": false,
"forceConsistentCasingInFileNames": true,
"noEmit": true,
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve",
"incremental": true
},
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"],
"exclude": ["node_modules"]
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment