Open oxypomme opened 1 year ago
Hi, Storybook 7 has been released, could you try upgrading using npx sb upgrade
and letting us know if that fixes your issue?
I just did and it only changed the core section by removing @storybook/builder-vite
- core: {
- builder: '@storybook/builder-vite',
- },
+ core: {},
And set versions of storybook to ^7.0.2
in package.json
& package-lock.json
.
The result of storybook dev
and storybook build
are the same
It should have also added a framework
to your main.js. But regardless, are you able to create a reproduction of the issue that we can look into?
It should have also added a framework to your main.js.
Yeah, framework
was already in the config.
But regardless, are you able to create a reproduction of the issue that we can look into?
When trying to replicate the issue, I found out that issue is from using import.meta.env
in the default value of a prop. So doing the following will crash :
export default defineComponent({
props: {
firstProp: {
type: String,
default: import.meta.env.FIRST_ENV_VAR,
},
secondProp: {
type: String,
default: 'some kind of prop',
},
},
});
But I can use env vars in other places, so I found a workaround by using a variable :
export default defineComponent({
props: {
firstProp: {
type: String,
- default: import.meta.env.FIRST_ENV_VAR,
+ default: ''
},
secondProp: {
type: String,
default: 'some kind of prop',
},
},
+ computed: {
+ // Actual value of firstProp
+ firstPropValue() {
+ return this.firstProp || import.meta.env.FIRST_ENV_VAR;
+ },
+ },
});
I don't think this is an issue with vite
or vue
(as storybook dev
or vite build
works) but it's kinda weird.
Am also seeing this issue with vite
and react
dev
works fine, but as soon as I try to run storybook build
it errors with Unexpected token (Note that you need plugins to import files that are not JavaScript)
whenever it comes across import.meta.env.VITE_XXX
Thank you for oxypomme!you helped me fix the error!!!good guy!
What version of
vite
are you using?4.2.1
System info and storybook versions
System: OS: Linux 5.14 Ubuntu 20.04.2 LTS (Focal Fossa) CPU: (20) x64 12th Gen Intel(R) Core(TM) i7-12700H Binaries: Node: 18.15.0 - ~/.nvm/versions/node/v18.15.0/bin/node Yarn: 1.22.19 - ~/.nvm/versions/node/v18.15.0/bin/yarn npm: 8.19.4 - ~/Documents/Work/ezreeport/node_modules/.bin/npm Browsers: Firefox: 111.0.1 npmPackages: @storybook/addon-essentials: ^7.0.0 => 7.0.2 @storybook/addon-interactions: ^7.0.0 => 7.0.2 @storybook/addon-links: ^7.0.0 => 7.0.2 @storybook/addons: ^7.0.0 => 7.0.2 @storybook/blocks: ^7.0.0 => 7.0.2 @storybook/testing-library: ^0.0.13 => 0.0.13 @storybook/vue: ^7.0.0 => 7.0.2 @storybook/vue-vite: ^7.0.0 => 7.0.2
Describe the Bug
I've got an issue where running
storybook dev
works and I can access storybook through a web browser with no problems ...... while running
storybook build
throws an errorParse error @:1:1
byvite:build-import-analysis
.(I skipped
watchFiles
and hidden paths because it doesn't seems revelent and yes, I tried to fix the issue with~/mixins/ezr.vue
and it didn't solve my problem)From what I understand, the issue may be from
EzrProvider.vue
while it that seems perfectly right :I also suspect that the issue may come from
.storybook/preview.ts
or.storybook/main.ts
:I think this issue is very specific to my setup, so I can't really reproduce in a codesandbox or something (tho I really like to) so I linked to the repo at a commit where the issue happens.
Link to Minimal Reproducible Example
https://github.com/ezpaarse-project/ezreeport/tree/19622bb039ef22177222b50f01eb57f683f39c1e/src/vue
Participation