Webpack extensions configuration is ignored
See original GitHub issueWhen using it like this, in a project that contains typescript files (.tsx compiles to .jsx)
const UniversalComponent = universal(({ page }) => import(`./pages/${page}`), {
minDelay: 500,
loading: Loading,
error: Err
})
Webpack tries to bundle all the files in that directory, including the .tsx files, even though there is no loader defined for it and the extensions is defined as
resolve: {
extensions: ['.jsx', '.js', '.sass', '.scss'],
},
To ignore the compile errors, I temporarily added the ignore-loader for .tsx files. Is there a way to configure this behaviour. Should I open this issue on webpack?
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Webpack ignores webpack.config.js - Stack Overflow
It's odd that using a webpack.config.js file in your project root isn't working. Check this webpack-demo project. I think it can help you...
Read more >IgnorePlugin - webpack
The following will cause those locale files to be ignored: new webpack.IgnorePlugin({ resourceRegExp: /^\.\/locale$/, contextRegExp: /moment$/, });.
Read more >Webstorm is ignoring module resolution rules in webpack ...
02:15 Can't analyse client.config.dev.ts: coding assistance will ignore module resolution rules in this file. Possible reasons: this file is not a valid ...
Read more >How to use the @expo/webpack-config/plugins ... - Snyk
plugin as any; // Replace HTML Webpack Plugin so we can interpolate it // @ts-ignore: webpack version mismatch config.plugins.splice(plugin.index, 1, new ...
Read more >Custom Webpack Config - Next.js
The webpack function is executed twice, once for the server and once for the client. This allows you to distinguish between client and...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
After having a look at
ContextModule
, it seems webpack tries to load a dependency first without an extension (./Home), then with the extensions found in that folder (./Home.jsx, ./Home.tsx).When using
ContextReplacementPlugin
regex option to filter the dependencies that are loaded I was left only with./Home.jsx
which resulted in a chunk namedpages/Home-jsx
that couldn’t be used.To workaround the issue I modified the regex to keep only the dependency without an extension (which actually resolves to the .jsx file according to my webpack config):
Using the above regex I get the desired outcome
Thanks for guiding me in the right direction.
glad to hear it! …been recommending this approach for a while, and you’re the first to finally prove it works.