Comments (7)
Does this solve your issue?
from karma-webpack.
Does this solve your issue?
You mean change name of output name?
package.json
"file-loader": "6.2.0"
{
loader: "file-loader",
options: {
name: (resourcePath, resourceQuery) => {
// `resourcePath` - `/absolute/path/to/file.js`
// `resourceQuery` - `?foo=bar`
if (this.isInDebugMode) {
return '[path][name].[ext]?[hash]';
}
return '[path][contenthash].[ext]';
},
outputPath: "images/",
publicPath: (this.cdnUrl || this.basePath) + this.clientBasePath + "images/"
}
};
Still got errors with this config of file-loader
from karma-webpack.
Nope, the bit about file-loader being deprecated, see the comment I linked.
from karma-webpack.
Nope, the bit about file-loader being deprecated, see the comment I linked.
Iยดam sorry but I dont understand where I have to set part from your linked comment.
Here is my webpack config where is file-loader
file-loader version is: 6.2.0
{
test: /\.(woff|woff2|eot|ttf|otf)$/,
use: [
{
loader: "file-loader",
options: {
name: "[name].[ext]",
outputPath: "fonts/"
}
}
]
},
{
test: /\.svg$/,
include: [
svgIconsPath
],
use: [
{
loader: 'svg-sprite-loader',
options: {
extract: true,
publicPath: this.basePath + this.clientBasePath + 'sprites/',
outputPath: 'sprites/',
spriteFilename: filePath => {
const prefix = path.dirname(path.relative(__dirname, filePath))
.split("\\")
.join("_");
return prefix + 'sprite-[hash:6].svg'
},
symbolId: filePath => {
return path.basename(filePath, ".svg") + svgMinifier.getNextIdent(filePath);
}
}
},
{
loader: "svgo-loader"
}
]
},
{
test: /\.svg$/,
exclude: [
svgIconsPath
],
use: [
this.buildFileLoaderForImage(),
{
loader: "svgo-loader"
}
]
},
{
test: /\.(png|jpg|gif|webp)$/,
use: [
this.buildFileLoaderForImage()
]
},
Here is buildFileLoaderForImage fnc:
buildFileLoaderForImage() {
return {
loader: "file-loader",
options: {
name: (resourcePath, resourceQuery) => {
// `resourcePath` - `/absolute/path/to/file.js`
// `resourceQuery` - `?foo=bar`
if (this.isInDebugMode) {
return '[path][name].[ext]?[fullhash]';
}
return '[path][contenthash].[ext]';
},
outputPath: "images/",
publicPath: (this.cdnUrl || this.basePath) + this.clientBasePath + "images/"
}
};
}
Error with import png:
Tsx Component:
import articleImg2 from "./images/buddy_itinerary_where.png";
Log:
[karma-server]: UnhandledRejection: Error: ENOENT: no such file or directory, open 'C:\Work\WORLDEE_WEB\client/../www/client//images/src/app/component
s/pages/Buddy-itinerary/images/buddy_itinerary_what.png?b50142538741d01bd7ac'
from karma-webpack.
Read this https://webpack.js.org/guides/asset-modules/
from karma-webpack.
I understand it, I have this issue after migrate to webpack 5. But normal build works. I have own settings of file-loader and it is not problem in build. Just only in karma.
from karma-webpack.
I fixed similar issue by removing the query value of my imported asset urls, e.g. change "buddy_itinerary_what.png?b50142538741d01bd7ac" to "buddy_itinerary_what.png"
from karma-webpack.
Related Issues (20)
- 5.0 crashes on MacOS (Preprocessor, Plugin), fixed on master -> Release 5.1? HOT 7
- Trying to add karma-webpack to angular karma config HOT 2
- karma.conf.js being treated as entrypoint results in many errors from webpack 5 HOT 2
- Webpack Errors being reported twice.
- Process is not defined HOT 1
- Webpack file cache isn't generated when webacpack watch option is false/nothing
- karma-webpack does not respect webpack mode = "production" HOT 3
- I have the same problem. HOT 1
- preprocessor change between v4 & v5 leading to error when used with karma-mocha HOT 15
- Issue with Webpack 5 unable to find file 404 (works with webpack 4) HOT 1
- Don't warn overriding [name].js to [name].js
- Figure out a publishing Github Workflow
- Ensure all project dependencies have no auditing issues
- Provide a migration path from karma-webpack
- Update the README.md
- Release 5.0.1 HOT 6
- Support Node >= 10 in 5.0.2 HOT 1
- Webpack `optimization` configuration is not supported anymore HOT 3
- Webpack configuration HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from karma-webpack.