Skip to content

Commit 844293e

Browse files
committed
add doc and test for resource attribute
1 parent 62215a8 commit 844293e

File tree

15 files changed

+222
-1
lines changed

15 files changed

+222
-1
lines changed

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,14 @@ Then, the settings for assets in html can be like this. That is to say, we put t
243243
<link rel="stylesheet" href="index">
244244
<script src="index"></script>
245245
```
246+
247+
If you hope to add attribute to the resource, please add it right before `src` or `rel`.
248+
249+
```javascript
250+
<script asycn defer src="libs/react"></script>
251+
<link asycn defer rel="stylesheet" href="index">
252+
```
253+
246254
But for favico, we can directly write like this:
247255
```javascript
248256
<link rel="shortcut icon" type="image/x-icon" href="favicon.ico">
@@ -392,3 +400,4 @@ If you still don't understand README, you can checkout examples in specWepback w
392400
- v1.2.0 support using loader and image in html
393401
- v1.2.2 fix bug from uglify js which remove quotes
394402
- v1.2.3 just chanage a few text
403+
- v1.2.4 add doc and test for resource attribute

README_ZH.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,12 @@ entry: {
242242
<script src="index"></script>
243243
```
244244

245+
如果你想给资源添加属性,请在`src``rel`之前添加。
246+
```javascript
247+
<script asycn defer src="libs/react"></script>
248+
<link asycn defer rel="stylesheet" href="index">
249+
```
250+
245251
而favico则直接配置:
246252
```javascript
247253
<link rel="shortcut icon" type="image/x-icon" href="favicon.ico">
@@ -392,3 +398,4 @@ plugins: [
392398
- v1.2.0 支持对html使用loader以及支持image插入到html中
393399
- v1.2.2 修复uglify js引入的,去掉引号无法匹配问题
394400
- v1.2.3 改了点小文案而已
401+
- v1.2.4 给资源属性添加文档与测试用例

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "html-res-webpack-plugin",
3-
"version": "1.2.3",
3+
"version": "1.2.4",
44
"description": "html generation and resource inline or md5 for webpack",
55
"keywords": [
66
"front-end",

spec/appSpec.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,3 +233,15 @@ describe("image-in-html", function() {
233233
expect(true).toBe(distContent === resultContent && checkImage);
234234
});
235235
});
236+
237+
describe("resource-attr-1", function() {
238+
it("=> resource atribute", function() {
239+
let distHtml = path.resolve('specWebpack/dist/resource-attr-1/index.html'),
240+
resultHtml = path.resolve('specWebpack/result/resource-attr-1/index.html');
241+
242+
let distContent = fs.readFileSync(distHtml).toString(),
243+
resultContent = fs.readFileSync(resultHtml).toString();
244+
245+
expect(true).toBe(distContent === resultContent);
246+
});
247+
});

specWebpack/.DS_Store

8 KB
Binary file not shown.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
html,
2+
body {
3+
margin: 0;
4+
padding: 0;
5+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<!doctype html>
2+
<html lang="zh">
3+
<head>
4+
<meta charset="utf-8">
5+
<title>Tencent QQ</title>
6+
<link async defer rel="stylesheet" href="//localhost:9000/./css/index-332d70.css">
7+
</head>
8+
<body>
9+
<div id="pages" class="qq-ui"></div>
10+
11+
12+
<script async defer src=//localhost:9000/js/index-332d70.js></script>
13+
</body>
14+
</html>
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
/******/ (function(modules) { // webpackBootstrap
2+
/******/ // The module cache
3+
/******/ var installedModules = {};
4+
5+
/******/ // The require function
6+
/******/ function __webpack_require__(moduleId) {
7+
8+
/******/ // Check if module is in cache
9+
/******/ if(installedModules[moduleId])
10+
/******/ return installedModules[moduleId].exports;
11+
12+
/******/ // Create a new module (and put it into the cache)
13+
/******/ var module = installedModules[moduleId] = {
14+
/******/ exports: {},
15+
/******/ id: moduleId,
16+
/******/ loaded: false
17+
/******/ };
18+
19+
/******/ // Execute the module function
20+
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
21+
22+
/******/ // Flag the module as loaded
23+
/******/ module.loaded = true;
24+
25+
/******/ // Return the exports of the module
26+
/******/ return module.exports;
27+
/******/ }
28+
29+
30+
/******/ // expose the modules object (__webpack_modules__)
31+
/******/ __webpack_require__.m = modules;
32+
33+
/******/ // expose the module cache
34+
/******/ __webpack_require__.c = installedModules;
35+
36+
/******/ // __webpack_public_path__
37+
/******/ __webpack_require__.p = "//localhost:9000/";
38+
39+
/******/ // Load entry module and return exports
40+
/******/ return __webpack_require__(0);
41+
/******/ })
42+
/************************************************************************/
43+
/******/ ([
44+
/* 0 */
45+
/***/ function(module, exports, __webpack_require__) {
46+
47+
module.exports = __webpack_require__(1);
48+
49+
50+
/***/ },
51+
/* 1 */
52+
/***/ function(module, exports, __webpack_require__) {
53+
54+
"use strict";
55+
56+
__webpack_require__(2);
57+
58+
var a = "hello world!";
59+
60+
/***/ },
61+
/* 2 */
62+
/***/ function(module, exports) {
63+
64+
// removed by extract-text-webpack-plugin
65+
66+
/***/ }
67+
/******/ ]);
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<!doctype html>
2+
<html lang="zh">
3+
<head>
4+
<meta charset="utf-8">
5+
<title>Tencent QQ</title>
6+
<link async defer rel="stylesheet" href="//localhost:9000/./css/index-332d70.css">
7+
</head>
8+
<body>
9+
<div id="pages" class="qq-ui"></div>
10+
11+
12+
<script async defer src=//localhost:9000/js/index-332d70.js></script>
13+
</body>
14+
</html>

specWebpack/runWebpack.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ var webpackConfig = [
2828
require(basePath + '/resource-copy-plugin-3/webpack.config.js'), // html mode usage with copy-webpack-plugin
2929
require(basePath + '/resource-external-1/webpack.config.js'), // external resource
3030
require(basePath + '/image-in-html/webpack.config.js'), // image in html
31+
require(basePath + '/resource-attr-1/webpack.config.js'), // resource attribute
3132
];
3233

3334
fs.removeSync(path.resolve('./specWebpack/dist/'));

0 commit comments

Comments
 (0)