electron-vite icon indicating copy to clipboard operation
electron-vite copied to clipboard

Possibility to change current working directory

Open Kinqdos opened this issue 1 year ago • 11 comments

Clear and concise description of the problem

It would be awesome I you can change the current working directory especially for the renderer. I you use libraries like postcss or tailwind you have to place those config at the root of the project rather than in src/renderer. Another example would be tanstack router. It searches for routes in src/routes and not in src/renderer/src/routes. To get around you have to place a config file at the route of the project to tell the router where to look for routes.

Suggested solution

A fix can be provided by executing the renderers vite instance from the src/renderer instead of executing it from the project root and tell vite only to find the files under src/renderer.

Alternative

An alternative solution can be provided by defining the location where vite gets executed from.

Additional context

No response

Validations

Kinqdos avatar Feb 15 '24 16:02 Kinqdos

How to parse postcss, tailwind configuration file is not determined by vite or electron-vite. For example, postcss is parsed through the postcss-load-config plugin, which can be configured through the css.postcss option in vite. The tanstack router can be customized through @tanstack/router-vite-plugin but not vite or electron-vite.

alex8088 avatar Feb 18 '24 03:02 alex8088

How to parse postcss, tailwind configuration file is not determined by vite or electron-vite. For example, postcss is parsed through the postcss-load-config plugin, which can be configured through the css.postcss option in vite. The tanstack router can be customized through @tanstack/router-vite-plugin but not vite or electron-vite.

The location where those libraries are searching for their config files is dependening from where you start vite. You can try it yourself if you run vite from the project root tailwind (for example) is looking for the tailwind.config.ts under / but if you first change directory to src/renderer and then run vite, tailwind is looking for the config under src/renderer. And this is what Im looking for. I want to place all config files wich are only related to the renderer (e.g. tailwind, postcss, tanstack router, ...) under src/renderer and not under /

Kinqdos avatar Feb 19 '24 15:02 Kinqdos

This seems unfeasible, build tools usually use the root directory as the working directory. Changing the working directory during the build process is obviously difficult and unpredictable. For example, Vite also can not read its postcss configuration in the specified directory unless postcss-load-config plugin support.

alex8088 avatar Feb 23 '24 16:02 alex8088

This is not what I meant, isn't it possible to just start vite renderer directory? For example in my web projects, I have an app/ directory and ui/ directory. And the package.json script I used to start vite was just "vite dev". But I changed it to "cd ui/ && vite dev" this way I can place all my config files that are just related to the frontend (tailwind, postcss, router, etc...) under ui/ and I dont have to place them under the project root directory (next to the package.json)

Kinqdos avatar Feb 23 '24 22:02 Kinqdos

So no chance to achieve what I want? Everyone has to mix config files from the renderer and the main process at the project root?

Kinqdos avatar Mar 01 '24 13:03 Kinqdos

Your idea is not very feasible, but the tanstack router you use can be customized via @tanstack/router-vite-plugin and postcss requires it to be in the root directory.

alex8088 avatar Mar 01 '24 14:03 alex8088

Are you having issues with the current implementation? because tailwind seems to work well at the root directory, i just had to update the tw config:

/** @type {import('tailwindcss').Config} */
module.exports = {
  content: ['./src/renderer/index.html', './src/renderer/src/**/*.{js,ts,jsx,tsx}'],
  theme: {
    extend: {}
  },
  plugins: []
}

clicktodev avatar Aug 27 '24 14:08 clicktodev