Skip to content

Commit

Permalink
chore(vite): Rename entry-client.tsx to entry.client (redwoodjs#8592)
Browse files Browse the repository at this point in the history
* chore(vite): Rename entry-client.tsx to entry.client

* Lint fix
  • Loading branch information
dac09 authored Jun 14, 2023
1 parent 41b7cc3 commit 3cfb6e3
Show file tree
Hide file tree
Showing 9 changed files with 13 additions and 31 deletions.
6 changes: 3 additions & 3 deletions __fixtures__/test-project/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@
"devDependencies": {
"@redwoodjs/vite": "6.0.0-canary.344",
"autoprefixer": "^10.4.14",
"postcss": "^8.4.23",
"postcss-loader": "^7.3.0",
"postcss": "^8.4.24",
"postcss-loader": "^7.3.3",
"prettier-plugin-tailwindcss": "^0.3.0",
"storybook": "^7.0.15",
"storybook": "^7.0.20",
"tailwindcss": "^3.3.2"
}
}
28 changes: 5 additions & 23 deletions packages/cli/src/commands/setup/vite/viteHandler.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import fs from 'fs'
import path from 'path'

import chalk from 'chalk'
import { Listr } from 'listr2'

import { addWebPackages } from '@redwoodjs/cli-helpers'
Expand All @@ -23,9 +22,7 @@ export const handler = async ({ force, verbose, addPackage }) => {
{
title: 'Adding vite.config.js...',
task: () => {
const viteConfigPath = `${getPaths().web.base}/vite.config.${
ts ? 'ts' : 'js'
}`
const viteConfigPath = getPaths().web.viteConfig

const templateContent = fs.readFileSync(
path.resolve(__dirname, 'templates', 'vite.config.ts.template'),
Expand Down Expand Up @@ -57,13 +54,10 @@ export const handler = async ({ force, verbose, addPackage }) => {
},
},
{
title: 'Creating new entry point in `web/src/entry-client.jsx`...',
title: 'Creating new entry point in `web/src/entry.client.jsx`...',
task: () => {
// Keep it as JSX for now
const entryPointFile = path.join(
getPaths().web.src,
`entry-client.jsx`
)
const entryPointFile = getPaths().web.entryClient

const content = fs
.readFileSync(
path.join(
Expand All @@ -85,22 +79,10 @@ export const handler = async ({ force, verbose, addPackage }) => {
title: 'Adding @redwoodjs/vite dependency...',
skip: () => {
if (!addPackage) {
return 'Skipping package install, you will need to add @redwoodjs/vite manaually as a dependency on the web workspace'
return 'Skipping package install, you will need to add @redwoodjs/vite manaually as a dev-dependency on the web workspace'
}
},
},
{
title: 'One more thing...',
task: (_ctx, task) => {
task.title = `One more thing...\n
${c.green('Vite Support is still experimental!')}
${c.green('Please let us know if you find bugs or quirks.')}
${chalk.hex('#e8e8e8')(
'https://github.com/redwoodjs/redwood/issues/new'
)}
`
},
},
],
{
rendererOptions: { collapseSubtasks: false },
Expand Down
4 changes: 2 additions & 2 deletions packages/create-redwood-app/tests/template.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ describe('template', () => {
"/web/src/Routes.tsx",
"/web/src/components",
"/web/src/components/.keep",
"/web/src/entry-client.tsx",
"/web/src/entry.client.tsx",
"/web/src/index.css",
"/web/src/index.html",
"/web/src/layouts",
Expand Down Expand Up @@ -154,7 +154,7 @@ describe('JS template', () => {
"/web/src/Routes.js",
"/web/src/components",
"/web/src/components/.keep",
"/web/src/entry-client.jsx",
"/web/src/entry.client.jsx",
"/web/src/index.css",
"/web/src/index.html",
"/web/src/layouts",
Expand Down
2 changes: 1 addition & 1 deletion packages/project-config/src/__tests__/paths.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -880,7 +880,7 @@ describe('paths', () => {
types: path.join(FIXTURE_BASEDIR, 'web', 'types'),
// Vite paths
viteConfig: path.join(FIXTURE_BASEDIR, 'web', 'vite.config.ts'),
entryClient: path.join(FIXTURE_BASEDIR, 'web/src/entry-client.tsx'),
entryClient: path.join(FIXTURE_BASEDIR, 'web/src/entry.client.tsx'),
},
}

Expand Down
2 changes: 1 addition & 1 deletion packages/project-config/src/paths.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ const PATH_WEB_DIR_GENERATORS = 'web/generators'
const PATH_WEB_DIR_CONFIG = 'web/config'
const PATH_WEB_DIR_CONFIG_WEBPACK = 'web/config/webpack.config.js'
const PATH_WEB_DIR_CONFIG_VITE = 'web/vite.config' // .js,.ts
const PATH_WEB_DIR_ENTRY_CLIENT = 'web/src/entry-client' // .jsx,.tsx
const PATH_WEB_DIR_ENTRY_CLIENT = 'web/src/entry.client' // .jsx,.tsx

const PATH_WEB_DIR_CONFIG_POSTCSS = 'web/config/postcss.config.js'
const PATH_WEB_DIR_CONFIG_STORYBOOK_CONFIG = 'web/config/storybook.config.js'
Expand Down
2 changes: 1 addition & 1 deletion packages/vite/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export default function redwoodPluginVite(): PluginOption[] {

if (!clientEntryPath) {
throw new Error(
'Vite client entry point not found. Please check that your project has an entry-client.{jsx,tsx} file in the web/src directory.'
'Vite client entry point not found. Please check that your project has an entry.client.{jsx,tsx} file in the web/src directory.'
)
}

Expand Down

0 comments on commit 3cfb6e3

Please sign in to comment.