<script setup> not working on root component in production build
See original GitHub issueVersion
4.5.11
Environment info
System:
OS: Windows 10 10.0.19041
CPU: (4) x64 Intel(R) Core(TM) i5-6600K CPU @ 3.50GHz
Binaries:
Node: 15.7.0 - C:\Program Files\nodejs\node.EXE
Yarn: Not Found
npm: 7.4.3 - C:\Program Files\nodejs\npm.CMD
Browsers:
Chrome: Not Found
Edge: Spartan (44.19041.423.0), Chromium (88.0.705.68)
npmGlobalPackages:
@vue/cli: Not Found
Steps to reproduce
Create new project with vue create testing (select vue3)
In App.vue change <script></script>
block to
<script setup>
/* eslint-disable */
import HelloWorld from "./components/HelloWorld.vue";
</script>
works:
Run: npm run serve
-> Everything works as expected;
does not work:
Run: npm run build
Serve dist directory (e.g. http-server) -> nothing gets rendered
What is expected?
Render App
What is actually happening?
App does not get rendered
I somehow have the feeling, that this was working before. This is only happening on the root App component. When I look the imported object, I don’t see any render function.
Cheers!
Issue Analytics
- State:
- Created 3 years ago
- Reactions:6
- Comments:15 (4 by maintainers)
Top Results From Across the Web
Vue 3 brakes when building for production using Options API ...
*Important note: It only fails when using "vite build" and it does not ... to script setup to augment missing component options like...
Read more >Vue 3: Support new <script setup> without ref sugar - YouTrack
js plugin would support it. It looks like plugin already supports most of new syntax, only issues I found are: when component is...
Read more >Understanding the new script setup with (defineProps ... - Netlify
Learn the fundamentals of Vue 3.2 script setup feature with ... But that's not all, we can also import and use components without...
Read more >How to fix the Whitescreen After a Static Deployment with ...
Loading failed for the <script> with source … ... the root of our problem. Your app does not know it's own location to...
Read more >Strict Mode - React
StrictMode is a tool for highlighting potential problems in an application. ... are run in development mode only; they do not impact the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
run:
can solve.
https://github.com/vuejs/vue-loader/issues/1838
I have also encountered this issue, but not just for the root component (with all SFCs).
I have not traced the cause, but a (verbose) workaround that has worked for me is to append a manual export of the
setup()
method to SFCs which use the<script setup>
syntax.In each SFC, append the following after the
<script setup>
block:Using Vue
3.1.1
:I had actually noted that serving the production
dist
directory (vue-cli-service serve --mode production
) intermittently worked with no change in config/code. I was not yet able to determine why this was the case.