Electron-vue: Not loading styles and images in production

Created on 11 Jul 2017  路  6Comments  路  Source: SimulatedGREG/electron-vue

To simply put it, my style.css and a couple of images are stored in the static folder. When i run "npm run dev" they all seem to work fine, with no console errors. When i run "npm run build" or any variation of it, it builds the app, however without any css, and images.

I see the images and css in the /dist/electron folder.

It might be my own stupidity cause i'm new at this, so what am i doing wrong?

question

Most helpful comment

@tposcic

It would be better to place your style.css inside of your src/renderer/assets directory and import like...

App.vue

@import "~@/assets/style.css";

The main benefit here, as opposed to placing in static/, is that webpack will be able to bundle the styles into the JS bundle to help produce a lighter build size. Closing since this isn't a direct issue with electron-vue, feel free to comment back any further questions.

Related: https://simulatedgreg.gitbooks.io/electron-vue/content/en/using_css_frameworks.html

All 6 comments

@tposcic

How are using importing your styles into your application?

@SimulatedGREG

I added this in App.vue

<style> @import url('https://fonts.googleapis.com/css?family=Source+Sans+Pro'); @import url('/static/css/style.css'); </style>

During the build process i can see '/static/css/style.css' listed as an asset.

@tposcic no problem for import font, but for the local style should not be used url () just import like this

@import url('https://fonts.googleapis.com/css?family=Source+Sans+Pro')
@import '/static/css/style.css'

@tposcic

It would be better to place your style.css inside of your src/renderer/assets directory and import like...

App.vue

@import "~@/assets/style.css";

The main benefit here, as opposed to placing in static/, is that webpack will be able to bundle the styles into the JS bundle to help produce a lighter build size. Closing since this isn't a direct issue with electron-vue, feel free to comment back any further questions.

Related: https://simulatedgreg.gitbooks.io/electron-vue/content/en/using_css_frameworks.html

Thank you for the help. I moved my style.css to src/renderer/assets and everything is working fine now. Great work on electron-vue!

No problem. Glad you got this resolved.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Oriol-GG picture Oriol-GG  路  3Comments

webrtcn picture webrtcn  路  3Comments

mvalim picture mvalim  路  4Comments

michalzaq12 picture michalzaq12  路  3Comments

rodrigomata picture rodrigomata  路  3Comments