
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
css-url-loader
Advanced tools
Webpack loader to transform URLs to other URLs in CSS.
Transform URLs to other URLs in the url()s in your CSS. You can change relative urls to absolute urls, or you can change old urls to new urls that you want.
npm install --save-dev css-url-loader
Or
yarn add --dev css-url-loader
When you want to trasform url(/assets/...) to url(https://domain/assets/...), the webpack.config.js is below
module.exports = {
module: {
rules: [
{
test: /\.css$/,
use: [
'css-loader',
{
loader: 'css-url-loader',
options: {
from: '/assets/',
to: 'https://domain/assets/'
}
}
],
},
],
}
}
When you want to trasform url(/assets/...) to url(/dir/assets/...), the webpack.config.js is below
module.exports = {
module: {
rules: [
{
test: /\.css$/,
use: [
'css-loader',
{
loader: 'css-url-loader',
options: {
from: '/assets/',
to: '/dir/assets/'
}
}
],
},
],
},
}
When you want to trasform urls when only development env, the webpack.config.js is below
module.exports = {
module: {
rules: [
{
test: /\.css$/,
use: [
'css-loader',
{
loader: 'css-url-loader',
options: {
from: '/assets/',
to: '/tmp/assets/',
env: 'development'
}
}
],
},
],
},
}
When you want to trasform urls when only development mode, the webpack.config.js is below
module.exports = {
module: {
rules: [
{
test: /\.css$/,
use: [
'css-loader',
{
loader: 'css-url-loader',
options: {
from: '/assets/',
to: '/tmp/assets/',
mode: 'development'
}
}
],
},
],
},
}
| Option | Description | Required |
|---|---|---|
| from | original url in url() | Yes |
| to | transformed url | Yes |
| env | process when env is equal to process.env.NODE_ENV. Default is 'production'. | No |
| mode | process when mode is equal to process.env.WEBPACK_MODE. Default is 'production'. | No |
FAQs
Webpack loader to transform URLs to other URLs in CSS.
We found that css-url-loader demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.