You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I'm having issues getting file-loader to work and I have noticed that the documentation seems to be contradicting itself in relation to the usage of this Webpack loader.
On the Using file-loader section it says that we should not use the file-loader directive directly, but rather use the fileLoader provided by the scripts API:
Do not use file-loader as a direct value. Import fileLoader from API and use it instead.
However the example given on the Nodejs API documentation it seems to be contradicting that information by using file-loader instead.
Regardless of what I try though, I can't get this feature to work though. I can get the script to log a path to the file, like this: //192.168.86.86:3000/wp-content/themes/themename/dist/app/assets/fig1-b2cdecd7.png but both browser console and the CLI output show:
./src/js/components/content/FrameCalculator/img/fig1.png 1:0
Module parse failed: Unexpected character '�' (1:0)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
(Source code omitted for this binary file)
Any clues to what I may be missing?
Currently my wpackio.project.js is setup like this (some parts omitted for brevity):
constpkg=require('./package.json');constpath=require('path');const{
getFileLoaderOptions,// getBabelPresets,// getDefaultBabelPresetOptions,
issuerForJsTsFiles,
issuerForNonJsTsFiles,
issuerForNonStyleFiles,// babelLoader,
fileLoader,// eslint-disable-next-line import/no-extraneous-dependencies}=require('@wpackio/scripts');constwebpackOverrideCallback=(config,merge,appDir,isDev)=>{constconfigWithSvg={module: {rules: [{test: /\.(svg|mp4|webm|webp|png)$/,use: [{loader: fileLoader,options: getFileLoaderOptions(appDir,isDev,false),},],issuer: issuerForNonStyleFiles,},{test: /\.(svg|mp4|webm|webp|png)$/,issuer: issuerForNonJsTsFiles,use: [{loader: fileLoader,options: getFileLoaderOptions(appDir,isDev,true),},],},],},};// merge our custom rule with webpack-mergereturnmerge(config,configWithSvg);};module.exports={// Project IdentityappName: 'appname',// Unique name of your projecttype: 'theme',// Plugin or themeslug: 'themename',// Plugin or Theme slug, basically the directory name under `wp-content/<themes|plugins>`// Files we need to compile, and where to putfiles: [{name: 'app',entry: {app: ['./src/js/app.js'],// Or an array of string (string[])},// If enabled, all WordPress provided external scripts, including React// and ReactDOM are aliased automatically. Do note that all `@wordpress`// namespaced imports are automatically aliased and enqueued by the// PHP library. It will not change the JSX pragma because of external// dependencies.optimizeForGutenberg: false,webpackConfig: webpackOverrideCallback,},],// Output path relative to the context directory// We need relative path here, else, we can not map to publicPathoutputPath: 'dist',// Project specific config// Needs react(jsx)?hasReact: true,};
The text was updated successfully, but these errors were encountered:
Hi, I'm having issues getting file-loader to work and I have noticed that the documentation seems to be contradicting itself in relation to the usage of this Webpack loader.
On the Using file-loader section it says that we should not use the
file-loader
directive directly, but rather use thefileLoader
provided by the scripts API:However the example given on the Nodejs API documentation it seems to be contradicting that information by using
file-loader
instead.Regardless of what I try though, I can't get this feature to work though. I can get the script to log a path to the file, like this:
//192.168.86.86:3000/wp-content/themes/themename/dist/app/assets/fig1-b2cdecd7.png
but both browser console and the CLI output show:Any clues to what I may be missing?
Currently my
wpackio.project.js
is setup like this (some parts omitted for brevity):The text was updated successfully, but these errors were encountered: