TypeError: url.replace is not a function
See original GitHub issue- Node Version: 16.4.2
- Yarn Version: 1.22.10
- webpack Version: 5.45.1
- mini-css-extract-plugin Version: 2.1.0
- css-loader Verion: 6.2.0
- @fortawesome/fontawesome-free" Version: 5.15.3
- css-minimizer-webpack-plugin: 3.0.2
Expected Behavior
Can Compiled successfully
Actual Behavior
Failed to compile
Module build failed (from ./node_modules/mini-css-extract-plugin/dist/loader.js):
TypeError: url.replace is not a function
Code
loader
const path = require('path');
const webpack = require('webpack');
const { VueLoaderPlugin } = require('vue-loader');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
module.exports = {
module: {
rules: [
{
test: /\.s[ac]ss$/i,
use: [
MiniCssExtractPlugin.loader,
"css-loader",
"postcss-loader",
"sass-loader"
],
},
{
test: /\.vue(\.erb)?$/,
use: { loader: 'vue-loader' },
options: {
postcss: [require('postcss-cssnext')()]
}
},
{
test: /\.(eot|svg|ttf|woff|woff2)(\?\S*)?$/,
loader: 'file-loader',
use: [
{
loader: 'file-loader',
options: {
name: 'font/[name].[ext]',
},
},
],
},
]
},
plugins: [
new webpack
.ContextReplacementPlugin(/\.\/locale$/, 'empty-module', false, /js$/),
new VueLoaderPlugin(),
new MiniCssExtractPlugin()
],
resolve: {
modules: [
path.resolve('./app/javascript/'),
],
alias: {
'~components': path.resolve('./app/javascript/components'),
'~commons': path.resolve('./app/javascript/commons'),
'~configuration': path.resolve('./app/javascript/packs/configuration'),
'~mixins': path.resolve('./app/javascript/mixins'),
'~mutations': path.resolve('./app/javascript/mutations'),
'~queries': path.resolve('./app/javascript/queries'),
'~pages': path.resolve('./app/javascript/pages'),
'~store': path.resolve('./app/javascript/store')
},
extensions: ['*', '.js', '.vue', '.json', '.css', '.sass', '.scss'],
},
};
application.scss
$fa-font-path: '~@fortawesome/fontawesome-free/webfonts';
@import '~@fortawesome/fontawesome-free/scss/fontawesome'; <--- error in here
How Do We Reproduce?
Please Add css-loader and @fortawesome/fontawesome-free and mini-css-extract-plugin and version on Top then compile.
Issue Analytics
- State:
- Created 2 years ago
- Comments:17 (7 by maintainers)
Top Results From Across the Web
Error: TypeError: url.replace is not a function #731 - GitHub
Error: TypeError: url.replace is not a function #731 ... module.exports = function escape(url) { // If url is already wrapped in quotes, ...
Read more >TypeError: replace is not a function in JavaScript | bobbyhadz
The "replace is not a function" error occurs when we call the replace() method on a value that is not of type string...
Read more >AngularJS JSONP TypeError: url.replace is not a function
I am trying to get URL using zillow api in angular JS. angular.module('account.settings').controller('AccountSettingsCtrl', ...
Read more >Fixed - Uncaught TypeError: a.replace is not a function
This does assume that newCount is a string, but this might not necessarily be the case - on initial page load this is...
Read more >TypeError: t.replace is not a function - WordPress.org
We are getting a console error which seems to be related to (not sure if it's ... TypeError: t.replace is not a function...
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 Free
Top 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
Thanks I will look at this in near future
Bug in
webpacker
, go tonode_modules/@rails/webpacker/package/rules/svg.js
and change content on:dataUrl
should returnstring
, notBuffer
https://github.com/webpack/webpack/blob/main/types.d.ts#L278, sorry we can’t fix it hereAlso if you faced with this issue most likely a problem:
file-loader
orurl-loader
and forgot to addtype: 'javascript/auto'
https://webpack.js.org/guides/asset-modules/ (no top), we strongly recommend migrate toasset modules
test
/include
/exclude
)@svgr/webpack
generate named export, not URL, so if you use this loader for allsvg
files you will have problems with HTML/CSS/other not js/jsxFeel free to feedback