Skip to content

Commit 883514c

Browse files
committed
add README.md
1 parent fefbbe8 commit 883514c

File tree

2 files changed

+38
-1
lines changed

2 files changed

+38
-1
lines changed

Diff for: README.md

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# A Webpack loader for replacing src and href of image, script and link tag
2+
3+
```js
4+
var ExtractTextPlugin = require('extract-text-webpack-plugin')
5+
var path = require('path')
6+
return {
7+
loader: {
8+
test: test,
9+
loader: ExtractTextPlugin.extract({
10+
use: {
11+
loader: 'jade-url-replace-loader',
12+
options: {
13+
attrs: ['img:src','script:src','link:href'],
14+
getEmitedFilePath: function (url) {
15+
if (!manifest) {
16+
// get filename with contenthash from manifest files
17+
// manifest file should be generated before hand
18+
var assetsRoot = path.join(__dirname, 'dist')
19+
var m1 = require(path.join(assetsRoot + '/manifest-js.json'))
20+
var m2 = require(path.join(assetsRoot + '/manifest-stylus.json'))
21+
var m3 = require(path.join(assetsRoot + '/manifest-img.json'))
22+
manifest = Object.assign({}, m1, m2, m3)
23+
console.log('Manifest:', manifest)
24+
}
25+
var pub = '/static/'
26+
var k = url.replace(pub, '')
27+
return pub + manifest[k]
28+
}
29+
}
30+
}
31+
})
32+
},
33+
plugins: [
34+
new ExtractTextPlugin('[name].jade')
35+
]
36+
}
37+
```

Diff for: package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "jade-url-replace-loader",
33
"version": "1.0.0",
4-
"description": "Replace src and href of image, script and link tag",
4+
"description": "A Webpack loader for replacing src and href of image, script and link tag",
55
"main": "index.js",
66
"scripts": {
77
"test": "mocha --reporter spec"

0 commit comments

Comments
 (0)