How to make CSS filter work in VueJS after building?











up vote
0
down vote

favorite












When developing locally running a Node server, my SVG filter works. However, it doesn't when I build it and run it on a server.



The VueJS project is using Webpack.



I build the app like this:



npm run build


I have the filter declared like this:






filter: url(#white-glow);





When I build the application, the CSS is in a subfolder (/static/css) and I suspect as a result it can't find the filter anymore. When I check the HTML source in my inspector, the SVG filter is there.



When I apply said filter as a style attribute in the HTML it works.






<button style="filter:url(#white-glow);" data-v-32012fc8="">music</button>





Edit: I cannot use the above method since I want the filter to be active only in the :active state, which you can't do with inline style attribute.



How can I make the filter available in the external CSS file after building the app?










share|improve this question




























    up vote
    0
    down vote

    favorite












    When developing locally running a Node server, my SVG filter works. However, it doesn't when I build it and run it on a server.



    The VueJS project is using Webpack.



    I build the app like this:



    npm run build


    I have the filter declared like this:






    filter: url(#white-glow);





    When I build the application, the CSS is in a subfolder (/static/css) and I suspect as a result it can't find the filter anymore. When I check the HTML source in my inspector, the SVG filter is there.



    When I apply said filter as a style attribute in the HTML it works.






    <button style="filter:url(#white-glow);" data-v-32012fc8="">music</button>





    Edit: I cannot use the above method since I want the filter to be active only in the :active state, which you can't do with inline style attribute.



    How can I make the filter available in the external CSS file after building the app?










    share|improve this question


























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      When developing locally running a Node server, my SVG filter works. However, it doesn't when I build it and run it on a server.



      The VueJS project is using Webpack.



      I build the app like this:



      npm run build


      I have the filter declared like this:






      filter: url(#white-glow);





      When I build the application, the CSS is in a subfolder (/static/css) and I suspect as a result it can't find the filter anymore. When I check the HTML source in my inspector, the SVG filter is there.



      When I apply said filter as a style attribute in the HTML it works.






      <button style="filter:url(#white-glow);" data-v-32012fc8="">music</button>





      Edit: I cannot use the above method since I want the filter to be active only in the :active state, which you can't do with inline style attribute.



      How can I make the filter available in the external CSS file after building the app?










      share|improve this question















      When developing locally running a Node server, my SVG filter works. However, it doesn't when I build it and run it on a server.



      The VueJS project is using Webpack.



      I build the app like this:



      npm run build


      I have the filter declared like this:






      filter: url(#white-glow);





      When I build the application, the CSS is in a subfolder (/static/css) and I suspect as a result it can't find the filter anymore. When I check the HTML source in my inspector, the SVG filter is there.



      When I apply said filter as a style attribute in the HTML it works.






      <button style="filter:url(#white-glow);" data-v-32012fc8="">music</button>





      Edit: I cannot use the above method since I want the filter to be active only in the :active state, which you can't do with inline style attribute.



      How can I make the filter available in the external CSS file after building the app?






      filter: url(#white-glow);





      filter: url(#white-glow);





      <button style="filter:url(#white-glow);" data-v-32012fc8="">music</button>





      <button style="filter:url(#white-glow);" data-v-32012fc8="">music</button>






      javascript css svg vue.js filter






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 9 at 14:07

























      asked Nov 9 at 1:53









      user1895910

      11




      11
























          2 Answers
          2






          active

          oldest

          votes

















          up vote
          0
          down vote













          The selector will not work like generic in an external css file.



          If you're using the filter only in one file you could theoretically define the rule in the external css file like this:



          filter: url(http://yourdomain.com/yourwebsite.html#white-glow);


          Although, this wouldn't really make sense, so I would suggest to place the filter in an external svg file as well and then address it with the full url to the external SVG file in your CSS file






          share|improve this answer





















          • Thanks! I can confirm this worked when done in my browser's inspector. I haven't tried building it with that path yet however.
            – user1895910
            Nov 9 at 16:40


















          up vote
          0
          down vote













          I have added a slash before my url. So now it looks like this in my Vue component and it parses fine when building. It looks like this now in both the component and the built CSS:



          filter: url('/#white-glow');


          I have successfully tested this in Firefox 47 and Chrome 70.



          Could anybody explain why this works?






          share|improve this answer























          • I tried to prefix it with ./ which didn't work.. Havent thought of just the / as that usually would be the root path of your domain.
            – Edwin Krause
            Nov 10 at 8:08













          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














           

          draft saved


          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53218753%2fhow-to-make-css-filter-work-in-vuejs-after-building%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          2 Answers
          2






          active

          oldest

          votes








          2 Answers
          2






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          0
          down vote













          The selector will not work like generic in an external css file.



          If you're using the filter only in one file you could theoretically define the rule in the external css file like this:



          filter: url(http://yourdomain.com/yourwebsite.html#white-glow);


          Although, this wouldn't really make sense, so I would suggest to place the filter in an external svg file as well and then address it with the full url to the external SVG file in your CSS file






          share|improve this answer





















          • Thanks! I can confirm this worked when done in my browser's inspector. I haven't tried building it with that path yet however.
            – user1895910
            Nov 9 at 16:40















          up vote
          0
          down vote













          The selector will not work like generic in an external css file.



          If you're using the filter only in one file you could theoretically define the rule in the external css file like this:



          filter: url(http://yourdomain.com/yourwebsite.html#white-glow);


          Although, this wouldn't really make sense, so I would suggest to place the filter in an external svg file as well and then address it with the full url to the external SVG file in your CSS file






          share|improve this answer





















          • Thanks! I can confirm this worked when done in my browser's inspector. I haven't tried building it with that path yet however.
            – user1895910
            Nov 9 at 16:40













          up vote
          0
          down vote










          up vote
          0
          down vote









          The selector will not work like generic in an external css file.



          If you're using the filter only in one file you could theoretically define the rule in the external css file like this:



          filter: url(http://yourdomain.com/yourwebsite.html#white-glow);


          Although, this wouldn't really make sense, so I would suggest to place the filter in an external svg file as well and then address it with the full url to the external SVG file in your CSS file






          share|improve this answer












          The selector will not work like generic in an external css file.



          If you're using the filter only in one file you could theoretically define the rule in the external css file like this:



          filter: url(http://yourdomain.com/yourwebsite.html#white-glow);


          Although, this wouldn't really make sense, so I would suggest to place the filter in an external svg file as well and then address it with the full url to the external SVG file in your CSS file







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 9 at 10:30









          Edwin Krause

          1,051921




          1,051921












          • Thanks! I can confirm this worked when done in my browser's inspector. I haven't tried building it with that path yet however.
            – user1895910
            Nov 9 at 16:40


















          • Thanks! I can confirm this worked when done in my browser's inspector. I haven't tried building it with that path yet however.
            – user1895910
            Nov 9 at 16:40
















          Thanks! I can confirm this worked when done in my browser's inspector. I haven't tried building it with that path yet however.
          – user1895910
          Nov 9 at 16:40




          Thanks! I can confirm this worked when done in my browser's inspector. I haven't tried building it with that path yet however.
          – user1895910
          Nov 9 at 16:40












          up vote
          0
          down vote













          I have added a slash before my url. So now it looks like this in my Vue component and it parses fine when building. It looks like this now in both the component and the built CSS:



          filter: url('/#white-glow');


          I have successfully tested this in Firefox 47 and Chrome 70.



          Could anybody explain why this works?






          share|improve this answer























          • I tried to prefix it with ./ which didn't work.. Havent thought of just the / as that usually would be the root path of your domain.
            – Edwin Krause
            Nov 10 at 8:08

















          up vote
          0
          down vote













          I have added a slash before my url. So now it looks like this in my Vue component and it parses fine when building. It looks like this now in both the component and the built CSS:



          filter: url('/#white-glow');


          I have successfully tested this in Firefox 47 and Chrome 70.



          Could anybody explain why this works?






          share|improve this answer























          • I tried to prefix it with ./ which didn't work.. Havent thought of just the / as that usually would be the root path of your domain.
            – Edwin Krause
            Nov 10 at 8:08















          up vote
          0
          down vote










          up vote
          0
          down vote









          I have added a slash before my url. So now it looks like this in my Vue component and it parses fine when building. It looks like this now in both the component and the built CSS:



          filter: url('/#white-glow');


          I have successfully tested this in Firefox 47 and Chrome 70.



          Could anybody explain why this works?






          share|improve this answer














          I have added a slash before my url. So now it looks like this in my Vue component and it parses fine when building. It looks like this now in both the component and the built CSS:



          filter: url('/#white-glow');


          I have successfully tested this in Firefox 47 and Chrome 70.



          Could anybody explain why this works?







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Nov 9 at 16:51

























          answered Nov 9 at 16:44









          user1895910

          11




          11












          • I tried to prefix it with ./ which didn't work.. Havent thought of just the / as that usually would be the root path of your domain.
            – Edwin Krause
            Nov 10 at 8:08




















          • I tried to prefix it with ./ which didn't work.. Havent thought of just the / as that usually would be the root path of your domain.
            – Edwin Krause
            Nov 10 at 8:08


















          I tried to prefix it with ./ which didn't work.. Havent thought of just the / as that usually would be the root path of your domain.
          – Edwin Krause
          Nov 10 at 8:08






          I tried to prefix it with ./ which didn't work.. Havent thought of just the / as that usually would be the root path of your domain.
          – Edwin Krause
          Nov 10 at 8:08




















           

          draft saved


          draft discarded



















































           


          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53218753%2fhow-to-make-css-filter-work-in-vuejs-after-building%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          how to define a CAPL function taking a sysvar argument

          Schultheiß

          Ansible :Unable to parse /etc/ansible/hosts as an inventory source