Skip to content

Commit 2faffde

Browse files
committed
update README.md
1 parent 7484172 commit 2faffde

File tree

3 files changed

+7
-14
lines changed

3 files changed

+7
-14
lines changed

README.md

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -28,24 +28,13 @@ module.exports = {
2828
{
2929
test: /\.css$/,
3030
use: [
31-
{
32-
loader: 'replace-css-url-loader',
33-
query: {
34-
replace: (url, file) => {
35-
console.log('now replacing css file', file)
36-
var match = /(?:https?:)\/\/at.alicdn.com\/t\/\w+.([^.]+)/.exec(url)
37-
return match ? '~static/antd/font.' + match[1] : url
38-
}
39-
}
40-
}
31+
'css-loader',
32+
'replace-css-url-loader'
4133
],
4234
},
4335
...
4436
],
4537
},
46-
resolve: {
47-
modules: [path.resolve(process.cwd(), 'assets'), 'node_modules'],
48-
}
4938
```
5039
5140
## Note

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "replace-css-url-loader",
33
"version": "1.0.4",
4-
"description": "Webpack loader to transform css urls using custom function",
4+
"description": "Webpack plugin to transform download cdn urls in css and replaced with local file path",
55
"main": "src/index.js",
66
"keywords": [
77
"webpack",

src/index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ module.exports = function (source, map, meta) {
2626
const {
2727
replace,
2828
match,
29+
showLog = true,
2930
saveDir = ['out', 'temp']
3031
} = loaderUtils.getOptions(this) || {};
3132

@@ -86,6 +87,9 @@ module.exports = function (source, map, meta) {
8687
filepath
8788
} = obj
8889
const newLink = relative(dirname(resourcePath), filepath) + (urlObj.search || '') + (urlObj.hash || '');
90+
if(showLog){
91+
console.log(`[replace-css-url]: "${link}" with "${newLink}"`)
92+
}
8993
return newLink
9094
} else {
9195
return link

0 commit comments

Comments
 (0)