Skip to content
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

trailingSlash: true errors when scaffolding a react app with batijs #1502

Closed
schaschko opened this issue Feb 19, 2024 · 4 comments
Closed

trailingSlash: true errors when scaffolding a react app with batijs #1502

schaschko opened this issue Feb 19, 2024 · 4 comments
Labels

Comments

@schaschko
Copy link

Description

  1. Scaffold: pnpm create @batijs/app --react

  2. Modify vite.config.ts to add trailingSlash: true:

import ssr from "vike/plugin";
import react from "@vitejs/plugin-react";
import { defineConfig } from "vite";
// add
import vike from 'vike/plugin'

export default defineConfig({
  plugins: [react({}), ssr({}),
    // add
    vike({
      // Make URLs end with a trailing slash.
      // For example: /some//path -> /some/path/
      trailingSlash: true,
    }),
  ],
});

Run:

pnpm install
pnpm build

Error:

> [email protected] build /home/fl/tmp/my-app
> vite build

error during build:
Error: [vike][Wrong Usage] Setting config.build.rollupOptions.output.assetFileNames is currently forbidden. (It's possible to support, thus contact a maintainer if you need this.)
    at file:///home/fl/tmp/my-app/node_modules/.pnpm/[email protected][email protected]/node_modules/vike/dist/esm/node/plugin/plugins/distFileNames.js:31:21
    at Array.forEach (<anonymous>)
    at configResolved (file:///home/fl/tmp/my-app/node_modules/.pnpm/[email protected][email protected]/node_modules/vike/dist/esm/node/plugin/plugins/distFileNames.js:15:27)
    at file:///home/fl/tmp/my-app/node_modules/.pnpm/[email protected]/node_modules/vite/dist/node/chunks/dep-stQc5rCc.js:67859:24
    at Array.map (<anonymous>)
    at resolveConfig (file:///home/fl/tmp/my-app/node_modules/.pnpm/[email protected]/node_modules/vite/dist/node/chunks/dep-stQc5rCc.js:67859:10)
    at build (file:///home/fl/tmp/my-app/node_modules/.pnpm/[email protected]/node_modules/vite/dist/node/chunks/dep-stQc5rCc.js:66730:20)
    at CAC.<anonymous> (file:///home/fl/tmp/my-app/node_modules/.pnpm/[email protected]/node_modules/vite/dist/node/cli.js:842:9)
 ELIFECYCLE  Command failed with exit code 1.

I also tried scaffolding a vike app without bati via pnpm create vike and then adding trailingSlash: true, here everything works. Is this not supported?

@phonzammi
Copy link
Member

@schaschko, I'm sorry, but why did you add import vike from 'vike/plugin' ?
FYI vike already imported with import ssr from "vike/plugin";.
so you only need to add trailingSlash: true inside ssr({})

@brillout
Copy link
Member

Thanks for creating the bug report, I will have a look at it tomorrow.

@schaschko
Copy link
Author

@schaschko, I'm sorry, but why did you add import vike from 'vike/plugin' ? FYI vike already imported with import ssr from "vike/plugin";. so you only need to add trailingSlash: true inside ssr({})

Thank you, this works. I did add it like that, because it's suggested in the docs.

@brillout
Copy link
Member

@schaschko Make sure to use 0.4.162-commit-6812418 as it includes a bug fix for trailingSlash.

Also, in case your company is up for it: #1350.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants