How I can make svg icons appear after spring-boot:run












0














I'm trying to place som icons from sprite.svg file



That's the fragment of my component in react, where I want to place image.
and webpack config. I placed sprite.svg in href, but it doesn't works. Am I need to change my webpack.config, or install some modules?



<div className="product__actions">
<div className="rating">
<svg width="20px" height="20px" xmlns="http://www.w3.org/1999/xlink">
<use xlinkHref="#icon-rating"/>
</svg>
<span className="rating__result">{this.props.product.money_value}</span>
</div>
</div>


that's my webpack config






const path = require('path');

module.exports = {
entry: {
home: './src/main/js/home/home.js',
products: './src/main/js/products/products.js',
....
_catalog: './src/main/resources/styles/_catalog.scss',
....

},
cache: true,
mode: 'development',
output: {
path: __dirname,
filename: './src/main/resources/static/built/[name].bundle.js'
},
module: {
rules: [
...
{
test: /.(ttf|eot|svg|woff(2)?)(?[a-z0-9=&.]+)?$/,
include: [path.join(__dirname, "src/assets")],
loader: "file-loader?name=assets/[name].[ext]"
}
...
]
},
plugins: [
new MiniCssExtractPlugin({
filename: './src/main/resources/static/css/[name].css'
}),
new MergeIntoSingleFilePlugin({
files: {
"./src/main/resources/static/styles/styles.css": [
'./src/main/resources/static/css/_catalog.css',
.....
]
}
})
]
};





How I can solve this problem, pls help!










share|improve this question




















  • 1




    You are missing a closing div tag on your html. Is that just a typo or is that how you have it in your code?
    – skellertor
    Dec 26 '18 at 17:57








  • 1




    It looks like the xlink attribute is deprecated. The documentation is developer.mozilla.org/en-US/docs/Web/SVG/Attribute/xlink:href. Try just using href
    – skellertor
    Dec 26 '18 at 18:04










  • Also, because you are camel casing xlinkHref react is probably treating it like a prop rather than a built in attribute.
    – skellertor
    Dec 26 '18 at 18:06










  • Thx for your response, tried to place href, div tag was just a typo, yes. Unfortunately nothing changes
    – PawMaw
    Dec 27 '18 at 9:15






  • 1




    Where is the #icon-rating element located?
    – skellertor
    Dec 27 '18 at 16:26
















0














I'm trying to place som icons from sprite.svg file



That's the fragment of my component in react, where I want to place image.
and webpack config. I placed sprite.svg in href, but it doesn't works. Am I need to change my webpack.config, or install some modules?



<div className="product__actions">
<div className="rating">
<svg width="20px" height="20px" xmlns="http://www.w3.org/1999/xlink">
<use xlinkHref="#icon-rating"/>
</svg>
<span className="rating__result">{this.props.product.money_value}</span>
</div>
</div>


that's my webpack config






const path = require('path');

module.exports = {
entry: {
home: './src/main/js/home/home.js',
products: './src/main/js/products/products.js',
....
_catalog: './src/main/resources/styles/_catalog.scss',
....

},
cache: true,
mode: 'development',
output: {
path: __dirname,
filename: './src/main/resources/static/built/[name].bundle.js'
},
module: {
rules: [
...
{
test: /.(ttf|eot|svg|woff(2)?)(?[a-z0-9=&.]+)?$/,
include: [path.join(__dirname, "src/assets")],
loader: "file-loader?name=assets/[name].[ext]"
}
...
]
},
plugins: [
new MiniCssExtractPlugin({
filename: './src/main/resources/static/css/[name].css'
}),
new MergeIntoSingleFilePlugin({
files: {
"./src/main/resources/static/styles/styles.css": [
'./src/main/resources/static/css/_catalog.css',
.....
]
}
})
]
};





How I can solve this problem, pls help!










share|improve this question




















  • 1




    You are missing a closing div tag on your html. Is that just a typo or is that how you have it in your code?
    – skellertor
    Dec 26 '18 at 17:57








  • 1




    It looks like the xlink attribute is deprecated. The documentation is developer.mozilla.org/en-US/docs/Web/SVG/Attribute/xlink:href. Try just using href
    – skellertor
    Dec 26 '18 at 18:04










  • Also, because you are camel casing xlinkHref react is probably treating it like a prop rather than a built in attribute.
    – skellertor
    Dec 26 '18 at 18:06










  • Thx for your response, tried to place href, div tag was just a typo, yes. Unfortunately nothing changes
    – PawMaw
    Dec 27 '18 at 9:15






  • 1




    Where is the #icon-rating element located?
    – skellertor
    Dec 27 '18 at 16:26














0












0








0







I'm trying to place som icons from sprite.svg file



That's the fragment of my component in react, where I want to place image.
and webpack config. I placed sprite.svg in href, but it doesn't works. Am I need to change my webpack.config, or install some modules?



<div className="product__actions">
<div className="rating">
<svg width="20px" height="20px" xmlns="http://www.w3.org/1999/xlink">
<use xlinkHref="#icon-rating"/>
</svg>
<span className="rating__result">{this.props.product.money_value}</span>
</div>
</div>


that's my webpack config






const path = require('path');

module.exports = {
entry: {
home: './src/main/js/home/home.js',
products: './src/main/js/products/products.js',
....
_catalog: './src/main/resources/styles/_catalog.scss',
....

},
cache: true,
mode: 'development',
output: {
path: __dirname,
filename: './src/main/resources/static/built/[name].bundle.js'
},
module: {
rules: [
...
{
test: /.(ttf|eot|svg|woff(2)?)(?[a-z0-9=&.]+)?$/,
include: [path.join(__dirname, "src/assets")],
loader: "file-loader?name=assets/[name].[ext]"
}
...
]
},
plugins: [
new MiniCssExtractPlugin({
filename: './src/main/resources/static/css/[name].css'
}),
new MergeIntoSingleFilePlugin({
files: {
"./src/main/resources/static/styles/styles.css": [
'./src/main/resources/static/css/_catalog.css',
.....
]
}
})
]
};





How I can solve this problem, pls help!










share|improve this question















I'm trying to place som icons from sprite.svg file



That's the fragment of my component in react, where I want to place image.
and webpack config. I placed sprite.svg in href, but it doesn't works. Am I need to change my webpack.config, or install some modules?



<div className="product__actions">
<div className="rating">
<svg width="20px" height="20px" xmlns="http://www.w3.org/1999/xlink">
<use xlinkHref="#icon-rating"/>
</svg>
<span className="rating__result">{this.props.product.money_value}</span>
</div>
</div>


that's my webpack config






const path = require('path');

module.exports = {
entry: {
home: './src/main/js/home/home.js',
products: './src/main/js/products/products.js',
....
_catalog: './src/main/resources/styles/_catalog.scss',
....

},
cache: true,
mode: 'development',
output: {
path: __dirname,
filename: './src/main/resources/static/built/[name].bundle.js'
},
module: {
rules: [
...
{
test: /.(ttf|eot|svg|woff(2)?)(?[a-z0-9=&.]+)?$/,
include: [path.join(__dirname, "src/assets")],
loader: "file-loader?name=assets/[name].[ext]"
}
...
]
},
plugins: [
new MiniCssExtractPlugin({
filename: './src/main/resources/static/css/[name].css'
}),
new MergeIntoSingleFilePlugin({
files: {
"./src/main/resources/static/styles/styles.css": [
'./src/main/resources/static/css/_catalog.css',
.....
]
}
})
]
};





How I can solve this problem, pls help!






const path = require('path');

module.exports = {
entry: {
home: './src/main/js/home/home.js',
products: './src/main/js/products/products.js',
....
_catalog: './src/main/resources/styles/_catalog.scss',
....

},
cache: true,
mode: 'development',
output: {
path: __dirname,
filename: './src/main/resources/static/built/[name].bundle.js'
},
module: {
rules: [
...
{
test: /.(ttf|eot|svg|woff(2)?)(?[a-z0-9=&.]+)?$/,
include: [path.join(__dirname, "src/assets")],
loader: "file-loader?name=assets/[name].[ext]"
}
...
]
},
plugins: [
new MiniCssExtractPlugin({
filename: './src/main/resources/static/css/[name].css'
}),
new MergeIntoSingleFilePlugin({
files: {
"./src/main/resources/static/styles/styles.css": [
'./src/main/resources/static/css/_catalog.css',
.....
]
}
})
]
};





const path = require('path');

module.exports = {
entry: {
home: './src/main/js/home/home.js',
products: './src/main/js/products/products.js',
....
_catalog: './src/main/resources/styles/_catalog.scss',
....

},
cache: true,
mode: 'development',
output: {
path: __dirname,
filename: './src/main/resources/static/built/[name].bundle.js'
},
module: {
rules: [
...
{
test: /.(ttf|eot|svg|woff(2)?)(?[a-z0-9=&.]+)?$/,
include: [path.join(__dirname, "src/assets")],
loader: "file-loader?name=assets/[name].[ext]"
}
...
]
},
plugins: [
new MiniCssExtractPlugin({
filename: './src/main/resources/static/css/[name].css'
}),
new MergeIntoSingleFilePlugin({
files: {
"./src/main/resources/static/styles/styles.css": [
'./src/main/resources/static/css/_catalog.css',
.....
]
}
})
]
};






javascript reactjs svg webpack






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Dec 26 '18 at 20:32









skellertor

350115




350115










asked Dec 26 '18 at 13:20









PawMawPawMaw

518




518








  • 1




    You are missing a closing div tag on your html. Is that just a typo or is that how you have it in your code?
    – skellertor
    Dec 26 '18 at 17:57








  • 1




    It looks like the xlink attribute is deprecated. The documentation is developer.mozilla.org/en-US/docs/Web/SVG/Attribute/xlink:href. Try just using href
    – skellertor
    Dec 26 '18 at 18:04










  • Also, because you are camel casing xlinkHref react is probably treating it like a prop rather than a built in attribute.
    – skellertor
    Dec 26 '18 at 18:06










  • Thx for your response, tried to place href, div tag was just a typo, yes. Unfortunately nothing changes
    – PawMaw
    Dec 27 '18 at 9:15






  • 1




    Where is the #icon-rating element located?
    – skellertor
    Dec 27 '18 at 16:26














  • 1




    You are missing a closing div tag on your html. Is that just a typo or is that how you have it in your code?
    – skellertor
    Dec 26 '18 at 17:57








  • 1




    It looks like the xlink attribute is deprecated. The documentation is developer.mozilla.org/en-US/docs/Web/SVG/Attribute/xlink:href. Try just using href
    – skellertor
    Dec 26 '18 at 18:04










  • Also, because you are camel casing xlinkHref react is probably treating it like a prop rather than a built in attribute.
    – skellertor
    Dec 26 '18 at 18:06










  • Thx for your response, tried to place href, div tag was just a typo, yes. Unfortunately nothing changes
    – PawMaw
    Dec 27 '18 at 9:15






  • 1




    Where is the #icon-rating element located?
    – skellertor
    Dec 27 '18 at 16:26








1




1




You are missing a closing div tag on your html. Is that just a typo or is that how you have it in your code?
– skellertor
Dec 26 '18 at 17:57






You are missing a closing div tag on your html. Is that just a typo or is that how you have it in your code?
– skellertor
Dec 26 '18 at 17:57






1




1




It looks like the xlink attribute is deprecated. The documentation is developer.mozilla.org/en-US/docs/Web/SVG/Attribute/xlink:href. Try just using href
– skellertor
Dec 26 '18 at 18:04




It looks like the xlink attribute is deprecated. The documentation is developer.mozilla.org/en-US/docs/Web/SVG/Attribute/xlink:href. Try just using href
– skellertor
Dec 26 '18 at 18:04












Also, because you are camel casing xlinkHref react is probably treating it like a prop rather than a built in attribute.
– skellertor
Dec 26 '18 at 18:06




Also, because you are camel casing xlinkHref react is probably treating it like a prop rather than a built in attribute.
– skellertor
Dec 26 '18 at 18:06












Thx for your response, tried to place href, div tag was just a typo, yes. Unfortunately nothing changes
– PawMaw
Dec 27 '18 at 9:15




Thx for your response, tried to place href, div tag was just a typo, yes. Unfortunately nothing changes
– PawMaw
Dec 27 '18 at 9:15




1




1




Where is the #icon-rating element located?
– skellertor
Dec 27 '18 at 16:26




Where is the #icon-rating element located?
– skellertor
Dec 27 '18 at 16:26












1 Answer
1






active

oldest

votes


















1














I should use correct full path to sprite.svg file



<use href="./resources/static/sprite.svg#icon-rating"/>


It works for me






share|improve this answer





















    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',
    autoActivateHeartbeat: false,
    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%2f53932664%2fhow-i-can-make-svg-icons-appear-after-spring-bootrun%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    I should use correct full path to sprite.svg file



    <use href="./resources/static/sprite.svg#icon-rating"/>


    It works for me






    share|improve this answer


























      1














      I should use correct full path to sprite.svg file



      <use href="./resources/static/sprite.svg#icon-rating"/>


      It works for me






      share|improve this answer
























        1












        1








        1






        I should use correct full path to sprite.svg file



        <use href="./resources/static/sprite.svg#icon-rating"/>


        It works for me






        share|improve this answer












        I should use correct full path to sprite.svg file



        <use href="./resources/static/sprite.svg#icon-rating"/>


        It works for me







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Dec 28 '18 at 10:55









        PawMawPawMaw

        518




        518






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53932664%2fhow-i-can-make-svg-icons-appear-after-spring-bootrun%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

            Mossoró

            Error while reading .h5 file using the rhdf5 package in R

            Pushsharp Apns notification error: 'InvalidToken'