jy0529 / vite-plugin-dynamic-publicpath

Use dynamic import handler to change runtime public base path, like webpack's __webpack_public_path__.
MIT License
46 stars 10 forks source link

Build error when using on vite@2.7.13 #11

Closed JeromeDeLeon closed 2 years ago

JeromeDeLeon commented 2 years ago

I'm getting an error below for vite:build-import-analysis when using this package with vite@2.7.13

I just followed the sample demo

vite v2.7.13 building for production...
✓ 4198 modules transformed.
rendering chunks (177)...[vite:build-import-analysis] Cannot read property 'type' of undefined
error during build:
TypeError: Cannot read property 'type' of undefined
    at Object.generateBundle (project-path\node_modules\vite\dist\node\chunks\dep-f5552faa.js:21192:27)
    at project-path\node_modules\vite\node_modules\rollup\dist\shared\rollup.js:22814:37
benjaminprojas commented 2 years ago

I am also getting this same error. Any idea why it's happening?

benjaminprojas commented 2 years ago

Turns out this is because assetsBase defaults to assets. If you manually set this to an empty string it fixes the issue.

assetsBase  : ''
JeromeDeLeon commented 2 years ago

Hmm, what's the point of assetsBase if we couldn't override it aside from setting it an empty string, I wonder? 🤔

benjaminprojas commented 2 years ago

Your guess is as good as mine. I think the default should be the empty string.

JeromeDeLeon commented 2 years ago

I was able to make it work after I put the same value as the one we use for build.assetsDir.