fix(nextjs): Formatting for pages (#28734)
<!-- Please make sure you have read the submission guidelines before posting an PR --> <!-- https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr --> <!-- Please make sure that your commit message follows our format --> <!-- Example: `fix(nx): must begin with lowercase` --> <!-- If this is a particularly complex change or feature addition, you can request a dedicated Nx release for this pull request branch. Mention someone from the Nx team or the `@nrwl/nx-pipelines-reviewers` and they will confirm if the PR warrants its own release for testing purposes, and generate it for you if appropriate. --> ## Current Behavior <!-- This is the behavior we have today --> ## Expected Behavior <!-- This is the behavior we should expect with the changes in this PR --> ## Related Issue(s) <!-- Please link the issue being fixed so it gets closed when this is merged. --> Fixes #28561
This commit is contained in:
parent
9a88ea8906
commit
0706c7f68c
@ -1,19 +1,16 @@
|
||||
<% if (style !== 'none') { %>
|
||||
<% if (styledModule && (styledModule === 'styled-jsx' || styledModule === 'styled-components')) {%>
|
||||
'use client';
|
||||
<% }%>
|
||||
<% if (styledModule && styledModule !== 'styled-jsx') {
|
||||
var wrapper = 'StyledPage';
|
||||
%>import styled from '<%= styledModule %>';<% } else {
|
||||
var wrapper = 'div';
|
||||
%>
|
||||
<%- (style !== 'styled-jsx' && style !== 'tailwind') ? `import styles from './page.module.${style}';` : '' %>
|
||||
<% }
|
||||
%>
|
||||
<%_ if (style !== 'none') { _%>
|
||||
<%_ if (styledModule && (styledModule === 'styled-jsx' || styledModule === 'styled-components')) { _%>
|
||||
'use client';
|
||||
<%_ } _%>
|
||||
<%_ if (styledModule && styledModule !== 'styled-jsx') { var wrapper = 'StyledPage'; _%>
|
||||
import styled from '<%= styledModule %>';
|
||||
<%_ } else { var wrapper = 'div'; _%>
|
||||
<%- (style !== 'styled-jsx' && style !== 'tailwind') ? `import styles from './page.module.${style}';` : '' %>
|
||||
<%_ } _%>
|
||||
|
||||
<% if (styledModule && styledModule !== 'styled-jsx') { %>
|
||||
const StyledPage = styled.div`<%- pageStyleContent %>`;
|
||||
<% }%>
|
||||
<%_ if (styledModule && styledModule !== 'styled-jsx') { _%>
|
||||
const StyledPage = styled.div`<%- pageStyleContent %>`;
|
||||
<%_ } _%>
|
||||
<% } %>
|
||||
export default function Index() {
|
||||
/*
|
||||
|
||||
@ -1,14 +1,14 @@
|
||||
import React from 'react';
|
||||
import { render } from '@testing-library/react';
|
||||
<% if (src && !appDir) { %>
|
||||
<%_ if (src && !appDir) { _%>
|
||||
import Index from '../src/pages/index';
|
||||
<% } else if (!appDir) { %>
|
||||
<%_ } else if (!appDir) { _%>
|
||||
import Index from '../pages/index';
|
||||
<% } else if (appDir && src) {%>
|
||||
<%_ } else if (appDir && src) { _%>
|
||||
import Page from '../src/app/page';
|
||||
<% } else { %>
|
||||
<%_ } else { _%>
|
||||
import Page from '../app/page';
|
||||
<% } %>
|
||||
<%_ } _%>
|
||||
|
||||
describe(<%- appDir ? `'Page'` : `'Index'` %>, () => {
|
||||
it('should render successfully', () => {
|
||||
|
||||
@ -1,17 +1,14 @@
|
||||
<% if (style !== 'none') { %>
|
||||
<% if (styledModule && styledModule !== 'styled-jsx') {
|
||||
var wrapper = 'StyledPage';
|
||||
%>import styled from '<%= styledModule %>';<% } else {
|
||||
var wrapper = 'div';
|
||||
%>
|
||||
<%- (style !== 'styled-jsx' && style !== 'tailwind') ? `import styles from './${fileName}.module.${style}';` : '' %>
|
||||
<% }
|
||||
%>
|
||||
<%_ if (style !== 'none') { _%>
|
||||
<%_ if (styledModule && styledModule !== 'styled-jsx') { var wrapper = 'StyledPage'; _%>
|
||||
import styled from '<%= styledModule %>';
|
||||
<% } else { var wrapper = 'div';%>
|
||||
<%- (style !== 'styled-jsx' && style !== 'tailwind') ? `import styles from './${fileName}.module.${style}';` : '' %>
|
||||
<%_ } _%>
|
||||
|
||||
<% if (styledModule && styledModule !== 'styled-jsx') { %>
|
||||
const StyledPage = styled.div`<%- pageStyleContent %>`;
|
||||
<% }%>
|
||||
<% } %>
|
||||
<%_ if (styledModule && styledModule !== 'styled-jsx') { _%>
|
||||
const StyledPage = styled.div`<%- pageStyleContent %>`;
|
||||
<%_ } _%>
|
||||
<%_ } _%>
|
||||
|
||||
export function Index() {
|
||||
/*
|
||||
|
||||
@ -1,9 +1,10 @@
|
||||
<%_ if (strict) { _%>import { StrictMode } from 'react';<%_ } _%>
|
||||
import * as ReactDOM from 'react-dom/client';
|
||||
<%_ if (routing) { _%>import { BrowserRouter } from 'react-router-dom';<%_ } _%>
|
||||
|
||||
import App from './app/<%= fileName %>';
|
||||
import './styles.<%= style %>'
|
||||
<%_ if(hasStyleFile) { _%>
|
||||
import './styles.<%= style %>'
|
||||
<%_ } _%>
|
||||
|
||||
const root = ReactDOM.createRoot(document.getElementById('root') as HTMLElement);
|
||||
<%_ if(strict && !routing) { _%>
|
||||
|
||||
@ -40,6 +40,7 @@ export async function createApplicationFiles(
|
||||
} else {
|
||||
styleSolutionSpecificAppFiles = '../files/style-css-module';
|
||||
}
|
||||
const hasStyleFile = ['scss', 'css', 'less'].includes(options.style);
|
||||
|
||||
const onBoardingStatus = await createNxCloudOnboardingURLForWelcomeApp(
|
||||
host,
|
||||
@ -64,6 +65,7 @@ export async function createApplicationFiles(
|
||||
appTests,
|
||||
inSourceVitestTests: getInSourceVitestTestsTemplate(appTests),
|
||||
style: options.style === 'tailwind' ? 'css' : options.style,
|
||||
hasStyleFile,
|
||||
};
|
||||
|
||||
if (options.bundler === 'vite') {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user