webpack-contrib / file-loader

File Loader
MIT License
1.86k stars 257 forks source link

why file-loader doesn't work ?! #332

Closed AlexyOd closed 5 years ago

AlexyOd commented 5 years ago
const path = require('path');
const ExtractTextPlugin = require("extract-text-webpack-plugin");

module.exports = {
  entry: './src/app.js',
  mode: 'development',
  output: {
    path: path.resolve(__dirname, 'dist'),
    filename: 'bundle.js'
  },
  module: {
    rules: [
    {
      test: /\.scss$/,
      use: ExtractTextPlugin.extract({
        fallback: 'style-loader',
        use: ['css-loader', 'sass-loader']
      })
    },
    {
      test: /.(png|svg|jpg)(\?[a-z0-9=\.]+)?$/,
      use: [
      {
        loader: 'file-loader',
        options: {
          name: '../dist/font/[name].[ext]',
        }
      }
      ]
    },
    {
      test: /.(woff(2)?|eot|ttf)(\?[a-z0-9=\.]+)?$/,
      use: [
      {
        loader: 'file-loader',
        options: {
          name: './dist/font/[hash].[ext]'

        }
      }
      ]
    },
    {
     test: /\.html$/,
     loader: "raw-loader"
   }
   ]
 },
 plugins: [
 new ExtractTextPlugin('style.css')
 ]
};
alexander-akait commented 5 years ago

It looks like you just deleted our lovely crafted issue template. It was there for good reasons. Please help us solving your issue by answering the questions asked in this template. I'm closing this. Please either update the issue with the template and reopen, or open a new issue.

You have invalid regexp in test

AlexyOd commented 5 years ago
test: /\.(jpg|jpeg|gif|png)$/, - doesn't work
test: /\.png$/, - doesn't work

test: /.(png|woff(2)?|eot|ttf|svg)(\?[a-z0-9=\.]+)?$/, - work, but not in my config