geoidesic / foundryvtt-actor-studio

A FoundryVTT module for creating Actors
MIT License
3 stars 1 forks source link

Allow building to a dist folder for yarn #39

Closed geoidesic closed 3 weeks ago

geoidesic commented 1 month ago

THIS IS STUPID Image Image Vauxs — 06/11/2024 10:04 PM Image yet it works geoidesic — 06/11/2024 10:13 PM So you created an import proxy? 😅 Now why didn't I think of that?

Screenshot 2024-06-15 at 02 39 14

Screenshot 2024-06-15 at 02 40 15

geoidesic commented 1 month ago

https://github.com/Pjb518/FoundryVTT-Level-Up-Official/blob/main/vite.config.js

tldr
        rollupOptions: {
            output: {
                assetFileNames: (assetInfo) => {
                    if (assetInfo.name === "style.css") {
                        return `${moduleJSON.id}.css`
                    }
                    return (assetInfo.name as string)
                },
            },
        },

plugins: [
  ...
        {
            name: 'change-names',
            configureServer(server) {
                server.middlewares.use((req: Connect.IncomingMessage & { url?: string }, res, next) => {
                    if (req.originalUrl?.includes(`/${packagePath}/`)) {
                        if (req.originalUrl === `/${packagePath}/dist/${moduleJSON.id}.js`) {
                            req.url = `/${packagePath}/dist/index.js`
                        }
                    }
                    next()
                })
            },
        },

(vite doesn't seem to have an option to rename the index.js file to anything else while in dev mode, so plugin it is)
geoidesic commented 3 weeks ago

This is now working