GithubHelp home page GithubHelp logo

Comments (6)

flootr avatar flootr commented on June 8, 2024 3

I don't guess that's the reason because, if I remove everything inside .modernizrrc (just leave {} ), webpack runs perfectly

Nevertheless, your loader configuration for Modernizr would not apply to the provided file because the regex does not match. The error message

Unexpected token (2:10)
You may need an appropriate loader to handle this file type.

is, at least in my experience, almost everytime caused by a "falsy" loader configuration. So there might be an issue there which is not caused by the modernizr-loader itself.

I cloned your repo and it happens to be that webpack is not recognizing your .modernizrrc as a json file. If you pass in the json-loader into your configuration like so

{
  test: /\.modernizrrc/,
  loader: 'modernizr-loader!json-loader'
},

it should run successfully.

However, I thought that webpack@2 is capable of reading json files. Maybe @jhnns has some input here. It might be due to the alias.

from modernizr-loader.

jhnns avatar jhnns commented on June 8, 2024 2

Webpack 2 will only apply the json-loader by default if the file extension is .json

from modernizr-loader.

CarpenterBug avatar CarpenterBug commented on June 8, 2024

I had a typo in the webpack.config.js resolve but it didn't fixed the issue.

.../Webpack2Setup/webpack.config.js (FIXED)

...
resolve: {
  alias: {
    modernizr$: __dirname + "/.modernizrrc"
  }
},
...

New error

ERROR in ./.modernizrrc
Module parse failed: .../Webpack2Setup/.modernizrrc Unexpected token (2:10)
You may need an appropriate loader to handle this file type.
| {
|   "minify": false,
|   "options": [
|     "setClasses"

from modernizr-loader.

flootr avatar flootr commented on June 8, 2024

Hey! This might be due to your loader configuration. You are expecting a /\.modernizrrc.js$/, but you are aliasing modernizr to .modernizrrc.

from modernizr-loader.

CarpenterBug avatar CarpenterBug commented on June 8, 2024

I don't guess that's the reason because, if I remove everything inside .modernizrrc (just leave {} ), webpack runs perfectly

from modernizr-loader.

CarpenterBug avatar CarpenterBug commented on June 8, 2024

@flootr you're right, I just needed to update the loader: 'modernizr-loader!json-loader'

That's a good question because I read somewhere that I didn't need json-loader with webpack 2. Probably I don't need to install it (I don't have it on my package.json) but I have to pass it into my configuration.

Thank you for your help 😄

from modernizr-loader.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.