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

Proxy css as js through alias #18193

Open
7 tasks done
zhangHongEn opened this issue Sep 24, 2024 · 5 comments
Open
7 tasks done

Proxy css as js through alias #18193

zhangHongEn opened this issue Sep 24, 2024 · 5 comments

Comments

@zhangHongEn
Copy link

zhangHongEn commented Sep 24, 2024

Describe the bug

ReferenceError: require is not defined

export default defineConfig({
  resolve: {
    alias: {
      "testpkg/b.css": "testpkg/proxy_b_css.js"
    }
  },
  optimizeDeps: {
    needsInterop: [
      "testpkg/proxy_b_css.js"
    ]
  },
  plugins: [vue()],
})

Reproduction

https://github.com/zhangHongEn/vite-wrap-css

Steps to reproduce

pnpm install && pnpm run dev

System Info

System:
    OS: macOS 14.3.1
    CPU: (8) arm64 Apple M2
    Memory: 2.78 GB / 24.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 18.20.2 - ~/.nvm/versions/node/v18.20.2/bin/node
    Yarn: 1.22.22 - ~/.nvm/versions/node/v18.20.2/bin/yarn
    npm: 10.5.0 - ~/.nvm/versions/node/v18.20.2/bin/npm
    pnpm: 9.6.0 - ~/.nvm/versions/node/v18.20.2/bin/pnpm
  Browsers:
    Safari: 17.3.1
  npmPackages:
    @vitejs/plugin-vue: ^5.1.2 => 5.1.4 
    vite: ^5.4.1 => 5.4.7

Used Package Manager

pnpm

Logs

No response

Validations

@sapphi-red
Copy link
Member

optimizeDeps.include needs to be used instead of optimizeDeps.needsInterop.

export default defineConfig({
  resolve: {
    alias: {
      "testpkg/b.css": "testpkg/proxy_b_css.js"
    }
  },
  optimizeDeps: {
    include: [
      "testpkg/proxy_b_css.js"
    ]
  },
  plugins: [vue()],
})

@zhangHongEn
Copy link
Author

zhangHongEn commented Sep 25, 2024 via email

@zhangHongEn
Copy link
Author

zhangHongEn commented Sep 25, 2024 via email

@sapphi-red sapphi-red reopened this Sep 25, 2024
@sapphi-red
Copy link
Member

What do you mean by "dynamically created during the build process"?

I guess I need a more complete reproduction.

@zhangHongEn
Copy link
Author

zhangHongEn commented Sep 25, 2024 via email

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

No branches or pull requests

2 participants