Problems to ignore URL in CSS

Asked

Viewed 51 times

0

As I do in Webpack for it to ignore content with images within the URL, e.g..

background-image: url("../img/marker.png");

I have a SASS file with this content:

// Fonts
@import url("http://fonts.googleapis.com/css?family=Roboto:300,400,700");
// Variables
@import "variables";
// Bootstrap
@import "~bootstrap-sass/assets/stylesheets/bootstrap";
// Font Awesome
@import "~font-awesome/css/font-awesome.css";
// CSS do Template
@import "../style.css";

And the webpack settings are like this:

plugins: [
    new webpack.ProvidePlugin({
        $: 'jquery',
        jQuery: 'jquery'
    })
],
module: {
    rules: [
        {
            test: /\.(png|jpg|gif)$/,
            use: [
                {
                    loader: 'file-loader',
                    options: {}
                }
            ]
        }
    ],
    loaders: [{

    }, {
        test: /\.css/,
        loader: ExtractTextPlugin.extract({
            use: [{
                loader: "css-loader",
                //options: { url: false }
            }]
        })
    }, {
        test: /\.(woff|.woff2|.ttf|.eot|.svg|.png|.jpg*.*)$/,
        loader: 'url-loader'
    }]
}

When I execute the npm run dev it presents me the following error:

> ERROR  Failed to compile with 2 errors                                                                                                                           14:57:24

These relative modules were not found:

* ../img/marker.png in ./node_modules/css-loader??ref--8-2!./node_modules/postcss-loader/lib??postcss!./resources/assets/style.css
* ../img/price-range-dragger.png in ./node_modules/css-loader??ref--8-2!./node_modules/postcss-loader/lib??postcss!./resources/assets/style.css

> ERROR in ./resources/assets/sass/app.scss
Module build failed: ModuleNotFoundError: Module not found: Error: Can't resolve '../img/marker.png' in 'D:\Dropbox\site-Frontend\resources\assets'
  • The error is stating that ../img/marker.png and ../img/price-range-dragger.png have not been found, the path is correct ?

  • @wmsouza this yes. I already checked. That’s why I want it to ignore when finding URL in css.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.