Skip to content
This repository has been archived by the owner on Mar 17, 2021. It is now read-only.

url-loader fails with error, when url src has query parameter in it. #30

Closed
ssreekanth opened this issue Mar 25, 2016 · 2 comments
Closed

Comments

@ssreekanth
Copy link

@font-face {
   font-family: "Ionicons";
   src: url("./ionicons.woff2?v=3.0.0-alpha.3") format("woff2"),
}

The above one fails with the error as follows -

ERROR in ./ionicons.woff2?v=3.0.0-alpha.3
Module parse failed: /Users/sreek/test/app/ionicons.woff2?v=3.0.0-alpha.3 Line 1: Unexpected token ILLEGAL
You may need an appropriate loader to handle this file type.
(Source code omitted for this binary file)
 @ ./ionicons.scss 6:85-120

where as, if I remove the version query parameter (?v=3.0.0-alpha.3) from the url src (as shown below), then it works just fine.

@font-face {
   font-family: "Ionicons";
   src: url("./ionicons.woff2") format("woff2"),
}

webpack.config.js

'use strict';
var path = require('path');
var ExtractTextPlugin = require("extract-text-webpack-plugin");
var APP = __dirname + '/app';

module.exports = {
    context: APP,
    entry: './index.js',
    output: {
        filename: 'bundle.js',
        path: __dirname + '/build'
    },
    module: {
        loaders: [
            {
                test: /\.(eot|woff|woff2|ttf|svg|png|jpg)$/,
                loader: 'url-loader?limit=1000&name=fonts/[name].[ext]'
            },
            {
                test: /\.(scss)$/,
                loader: ExtractTextPlugin.extract("css!postcss!sass"),
            },
        ]
    },
    plugins: [
        new ExtractTextPlugin("css/[name].css")
    ]
};

Is this an issue with url-loader? If not, any suggestions to get this working, when url src has query parameter appended to it?

Appreciate your time!

@bearcott
Copy link

bearcott commented Apr 7, 2016

my guess is that your regex doesn't it if there is an extra param. try adding (\?[\s\S]+)?:

    {
      test: /\.(ttf|woff|eot|svg)(\?[\s\S]+)?$/,
      loader: 'url-loader'
    }

@ssreekanth
Copy link
Author

Thanks a lot @bearcott ! That worked.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants