W
W
Wasya UK2019-03-12 13:30:40
webpack
Wasya UK, 2019-03-12 13:30:40

How to set path for files in sass-loader?

I have a config, everything is fine, but when processing a sass file, I get the /css prefix to all pictures and fonts . The problem is that they are stored in the directory below, i.e. I need to specify the path for all these files:
Now
dist/css/img/Flowering_trees_Sakura_4.jpg
Should be:
dist/img/Flowering_trees_Sakura_4.jpg
In css:

background-image: url(img/Flowering_trees_Sakura_427376.jpg);

And it should be:
background-image: url(../img/Flowering_trees_Sakura_427376.jpg);

Config:
{
        test: /\.sass$/,
        use: [
          {
            loader: 'file-loader',
            options: {
              name: 'css/[name].css'
              // какая опция отвечает за путь к статическим файлам
            }
          },
          'extract-loader',
          'css-loader',
          'postcss-loader',
          'sass-loader'
        ]
      },

Answer the question

In order to leave comments, you need to log in

1 answer(s)
W
Wasya UK, 2019-03-12
@dmc1989

output: {
    path: webpackData.distDir,
    filename: 'js/[name].js',
    publicPath: '../'
  },

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question