dynamic component import not imported in build
See original GitHub issueDo NOT ignore this template or your issue will have a very high chance to be closed without comment.
Describe the bug
When i import dynamically a component, everything work on dev, but the component doesn’t exist on build.
I import component with this function
const importPage = path => () => import(`./pages/${path}.vue`)
When i build, the CSS is not created. (because the css is only in this page)
But when i manually import the component import Home from '/~/pages/home/Home.vue'
The CSS is here.
System Info
- required
vite
version: v1.0.0-rc.3 - required Operating System: Linux
- required Node version: v12.11.1
- Optional:
- npm/yarn version: 1.12.3
- Installed
vue
version (fromyarn.lock
orpackage-lock.json
) 3.0.0-rc.4 - Installed
@vue/compiler-sfc
version 3.0.0-rc.4
Logs (Optional if provided reproduction)
Without import Home from '/~/pages/home/Home.vue'
With import Home from '/~/pages/home/Home.vue'
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:8 (4 by maintainers)
Top Results From Across the Web
Dynamic import of component fails - vue.js - Stack Overflow
Depending on what's happening in your file, you sometimes cannot dynamically import a component. Let's say if you need some values right ...
Read more >Dynamically Importing Components with React.lazy
Not all static imports are immediately needed, and unnecessary imports can be costly. With React.lazy, you can dynamically import components ...
Read more >[SOLVED] - Dynamic import not working - help - Meteor forums
Hey there! I'm trying to implement dynamic loading to split the code per page to minimise the main bundle size cause the app...
Read more >Advanced Features: Dynamic Import - Next.js
Dynamically import JavaScript modules and React Components and split your code ... By using next/dynamic , the header component will not be included...
Read more >Features | Vite
Native ES imports do not support bare module imports like the following: ... Vite provides first-party HMR integrations for Vue Single File Components...
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
This is expected behavior.For the css of dynamic module will be packaged into js.
This works with vue-cli (webpack) but not in vite, you could also iterate an array of filenames and require each of them before build on vue-cli. It was very helpful for code splitting.