1.0.3 • Published 7 years ago
css-url-prefix-loader v1.0.3
css-url-prefix-loader
Webpack loader to transform URLs to other URLs in CSS.
Description
Transform URLs to other URLs in the url()s in your CSS.
Install
npm install --save-dev cross-envnpm install --save-dev css-url-prefix-loaderOr
yarn add --dev css-url-prefix-loaderUsage
When you want to trasform url(/images/...) to url(https://dev.com/images/...) or url(https://live.com/images/...), the webpack.config.js is below
module.exports = {
...
module: {
rules: [
...
{
test: /\.css$/,
use: ExtractTextPlugin.extract({
fallback: 'style-loader',
use: [
'css-loader',
{
loader: 'css-url-prefix-loader',
query: {
from: '/images',
dev: 'https://dev.com',
live: 'https://live.com'
}
}
],
}),
},
...
],
},
plugins: [
...
new ExtractTextPlugin('bundle.css'),
...
],cross-env NODE_ENV=dev webpack --config webpack.config.jsOr
cross-env NODE_ENV=live webpack --config webpack.config.js