Question regarding static CSS file
See original GitHub issueFirst, thanks for this awesome project! Itβs been a huge help to give me a starting point for my app.
I am using ElementUI in my project, and I have generated a custom theme. I have two questions about how to include this stylesheet in my project:
- Where is the proper place to put this file? I am assuming I should use the
/static
directory? - How should I be including the file? I know that
/src/index.ejs
automatically includes any stylesheets that are imported in/src/renderer/main.js
(for example,import 'bulma/css/bulma.css'
). But as this is a static file and not part of a node module, I cannot import the stylesheet in this way.
My current solution is to place the file in the /static
directory, and manually add it to the <head>
tag in /src/index.ejs
(eg. <link rel="stylesheet" href="static/theme.css">
), but will that work in production?
Thanks!
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:6 (1 by maintainers)
Top Results From Across the Web
How to refer to static files in my css files? - Stack Overflow
Use a relative path. Relative to the folder where the css file reside.
Read more >Top 30+ CSS Interview Questions (2023) - InterviewBit
Find top CSS interview questions asked. Explore basic, intermediate, and advanced level questions.
Read more >Top 75+ CSS Interview Questions You Should Prepare
Cover the top CSS interview questions asked by popular companies. Prepare for the frequently ask'd CSS questions from beginners to advancedΒ ...
Read more >When to Use Static CSS File Generation. : r/divi - Reddit
Hello. I am new to web development and using Divi in particular. I have a question regarding static CSS file generation.
Read more >Top 50 HTML Interview Questions and Answers in 2023
HTML is one of the most widely used languages on Web to develop web pages. ... When you try to open the external...
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 Free
Top 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
I had similar questions. I found it suprisingly complicated to go through the number of possibilities, without reading tons of barely-related documentation, given that you have to build the app to check whether the production app is also ok, while its config is different.
I :
generated-custom-style.css
and that refer to some fonts (FontAwesome & open-iconic) with paths like../fonts
my-style-global-tweaks.css
<i class="fa fa-...">
url('<path>');
Finally, after many trials and errors, I came up with the following setup:
and then:
my-style-tweaks.css
, I can usebackground: url('~@/assets/img/...')
(note the~@/
, coming from here).Component.vue
file, in the<template>
section, I can use<img id="logo" src="static/img/logo-circle.png">
(note the absence of any~
,@
,./
etcβ¦)src/renderer/main.js
I have a lineimport 'bootstrap3/dist/css/bootstrap.min.css'
<style>
section of theApp.vue
file, I load all global stuff:It works in dev and prod.
Iβm happy if anyone come up with a better solution. As for now, Iβll try to produce some real stuffβ¦
Thereβs a guide for the usage of static files in the documentation, right here!
https://simulatedgreg.gitbooks.io/electron-vue/content/en/using-static-assets.html