question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Hi,

I have an ejected CRA app where I am trying to integrate semantic-ui-less. Here is my webpack.dev.config https://gist.github.com/benoj/908f20a64066ca8606733c36206bccdd (not much changed)

However, when I require the less files I am getting the following issue:

Module build failed:

module.exports = __webpack_public_path__ + "static/media/accordion.8c4c433e.less";
             ^
Unrecognised input
      in /Users/benflowers/Projects/candidate/candidate-ui-cra/node_modules/semantic-ui-less/definitions/modules/accordion.less (line 1, column 15)

Is there anything specific with CRA configuration which could be causing this?

I have asked on StackOverflow and Webpack Gitter but not getting any response

Cheers,

Ben

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

6reactions
NDev8commented, Feb 24, 2018

I hope the comment is not too late but think it has to do with the standard file-loader rule in the oneOf: [...] rule of your webpack.config.* file. It was the same problem as you described.

I have changed the exclude statement of the standard file-loader:

          {
            // Exclude `js` files to keep "css" loader working as it injects
            // its runtime that would otherwise processed through "file" loader.
            // Also exclude `html` and `json` extensions so they get processed
            // by webpacks internal loaders.
            exclude: [/\.(js|jsx|mjs)$/, /\.html$/, /\.json$/],
            loader: require.resolve('file-loader'),
            options: {
              name: 'static/media/[name].[hash:8].[ext]',
            },
          },

from this:

exclude: [/\.(js|jsx|mjs)$/, /\.html$/, /\.json$/],

to this:

exclude: [/\.(js|jsx|mjs)$/, /\.html$/, /\.json$/, /\.(less|config|variables|overrides)$/],

This excludes all .less, .config, .variables and .overrides files from the file-loader. I think it’s not the best solution but it worked for me and produced no other errors.

0reactions
grinichcommented, Oct 21, 2018

So after reading through all the code and starting to grok how this stuff all works…

It turns out you can use the same react-app-rewired config-overrides.js file to modify the loader. This is the same way that the re-writing modules do it. Something like this should do the trick, and without ejecting. 🎉

const { getLoader, loaderNameMatches } = require('react-app-rewired')
const rewireLess = require('react-app-rewire-less')

module.exports = function override(config, env) {
  config = rewireLess(config, env)

  const extensionsToExclude = /\.(less|config|variables|overrides)$/;

  const fileLoader = getLoader(
    config.module.rules,
    rule => loaderNameMatches(rule, 'file-loader')
  );
  fileLoader.exclude.push(extensionsToExclude)

  return config
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Less module build failed in webpack after migrating from grunt
I can't figure out how to compile my less files to css and then include them in my build folder, without the app...
Read more >
Command Line Usage - Less CSS
Compile .less files to .css using the command line. Heads up! ... Default: html. Set the method of error reporting when compilation fails....
Read more >
#58935 (go @1.13: build fails on 10.9 and less) – MacPorts
I saw this on my 10.7 system this morning, and <​https://ports.macports.org/port/go/builds> shows it affects 10.9 and less.
Read more >
807974 - Be less chatty when the build fails - Bugzilla@Mozilla
Here's what mach currently shows: Error running mach: ['build'] The error occured in code that was called by the mach command. This is...
Read more >
CSS, SCSS, and Less support in Visual Studio Code
Find out how Visual Studio Code can support your CSS, SCSS and Less ... Note: If your build fails or you see an...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found