Skip to content

Commit adb8c28

Browse files
authored
Merge pull request #266 from ant-tool/add-test-about-font
breaking: eot file use url-loader instead of file-loader and add tes…
2 parents 5ccfca9 + 1a6c813 commit adb8c28

File tree

13 files changed

+194
-1
lines changed

13 files changed

+194
-1
lines changed

src/getWebpackCommonConfig.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,9 @@ export default function getWebpackCommonConfig(args) {
157157
loader: `${require.resolve('url-loader')}?` +
158158
`limit=10000&minetype=application/octet-stream`,
159159
},
160-
{ test: /\.eot(\?v=\d+\.\d+\.\d+)?$/, loader: `${require.resolve('file-loader')}` },
160+
{ test: /\.eot(\?v=\d+\.\d+\.\d+)?$/, loader: `${require.resolve('url-loader')}?` +
161+
`limit=10000&minetype=application/vnd.ms-fontobject`,
162+
},
161163
{
162164
test(filePath) {
163165
return /\.svg$/.test(filePath) && !/\.icon\.svg/.test(filePath);

test/build-test.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,4 +97,7 @@ describe('lib/build', function () {
9797
it('should support svg sprite', () => {
9898
return testBuild({}, 'build-svg-sprite');
9999
});
100+
it('should support font', () => {
101+
return testBuild({}, 'build-font');
102+
});
100103
});

test/expect/build-font/common.js

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
/******/ (function(modules) { // webpackBootstrap
2+
/******/ // install a JSONP callback for chunk loading
3+
/******/ var parentJsonpFunction = window["webpackJsonp"];
4+
/******/ window["webpackJsonp"] = function webpackJsonpCallback(chunkIds, moreModules) {
5+
/******/ // add "moreModules" to the modules object,
6+
/******/ // then flag all "chunkIds" as loaded and fire callback
7+
/******/ var moduleId, chunkId, i = 0, callbacks = [];
8+
/******/ for(;i < chunkIds.length; i++) {
9+
/******/ chunkId = chunkIds[i];
10+
/******/ if(installedChunks[chunkId])
11+
/******/ callbacks.push.apply(callbacks, installedChunks[chunkId]);
12+
/******/ installedChunks[chunkId] = 0;
13+
/******/ }
14+
/******/ for(moduleId in moreModules) {
15+
/******/ if(Object.prototype.hasOwnProperty.call(moreModules, moduleId)) {
16+
/******/ modules[moduleId] = moreModules[moduleId];
17+
/******/ }
18+
/******/ }
19+
/******/ if(parentJsonpFunction) parentJsonpFunction(chunkIds, moreModules);
20+
/******/ while(callbacks.length)
21+
/******/ callbacks.shift().call(null, __webpack_require__);
22+
/******/ if(moreModules[0]) {
23+
/******/ installedModules[0] = 0;
24+
/******/ return __webpack_require__(0);
25+
/******/ }
26+
/******/ };
27+
28+
/******/ // The module cache
29+
/******/ var installedModules = {};
30+
31+
/******/ // object to store loaded and loading chunks
32+
/******/ // "0" means "already loaded"
33+
/******/ // Array means "loading", array contains callbacks
34+
/******/ var installedChunks = {
35+
/******/ 0:0
36+
/******/ };
37+
38+
/******/ // The require function
39+
/******/ function __webpack_require__(moduleId) {
40+
41+
/******/ // Check if module is in cache
42+
/******/ if(installedModules[moduleId])
43+
/******/ return installedModules[moduleId].exports;
44+
45+
/******/ // Create a new module (and put it into the cache)
46+
/******/ var module = installedModules[moduleId] = {
47+
/******/ exports: {},
48+
/******/ id: moduleId,
49+
/******/ loaded: false
50+
/******/ };
51+
52+
/******/ // Execute the module function
53+
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
54+
55+
/******/ // Flag the module as loaded
56+
/******/ module.loaded = true;
57+
58+
/******/ // Return the exports of the module
59+
/******/ return module.exports;
60+
/******/ }
61+
62+
/******/ // This file contains only the entry chunk.
63+
/******/ // The chunk loading function for additional chunks
64+
/******/ __webpack_require__.e = function requireEnsure(chunkId, callback) {
65+
/******/ // "0" is the signal for "already loaded"
66+
/******/ if(installedChunks[chunkId] === 0)
67+
/******/ return callback.call(null, __webpack_require__);
68+
69+
/******/ // an array means "currently loading".
70+
/******/ if(installedChunks[chunkId] !== undefined) {
71+
/******/ installedChunks[chunkId].push(callback);
72+
/******/ } else {
73+
/******/ // start chunk loading
74+
/******/ installedChunks[chunkId] = [callback];
75+
/******/ var head = document.getElementsByTagName('head')[0];
76+
/******/ var script = document.createElement('script');
77+
/******/ script.type = 'text/javascript';
78+
/******/ script.charset = 'utf-8';
79+
/******/ script.async = true;
80+
81+
/******/ script.src = __webpack_require__.p + "" + ({"1":"index"}[chunkId]||chunkId) + ".js";
82+
/******/ head.appendChild(script);
83+
/******/ }
84+
/******/ };
85+
86+
/******/ // expose the modules object (__webpack_modules__)
87+
/******/ __webpack_require__.m = modules;
88+
89+
/******/ // expose the module cache
90+
/******/ __webpack_require__.c = installedModules;
91+
92+
/******/ // __webpack_public_path__
93+
/******/ __webpack_require__.p = "";
94+
/******/ })
95+
/************************************************************************/
96+
/******/ ([]);

test/expect/build-font/index.css

Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/expect/build-font/index.html

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<html>
2+
<head>
3+
<meta charset="utf-8"/>
4+
<title>webfont</title>
5+
<style type="text/css">
6+
*{margin: 0;padding: 0;list-style: none;}
7+
</style>
8+
<script src="./common.js"></script>
9+
<script src="./index.js"></script>
10+
<link href="./index.css" rel="stylesheet" type="text/css" />
11+
</head>
12+
<body>
13+
<h1>webfont 字体预览</h1>
14+
<p class="web-font">英雄不问出路,流氓不看岁数</p>
15+
</body>
16+
</html>

test/expect/build-font/index.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
webpackJsonp([1,0],[
2+
/* 0 */
3+
/***/ (function(module, exports, __webpack_require__) {
4+
5+
'use strict';
6+
7+
__webpack_require__(1);
8+
9+
__webpack_require__(2);
10+
11+
/***/ }),
12+
/* 1 */
13+
/***/ (function(module, exports) {
14+
15+
// removed by extract-text-webpack-plugin
16+
17+
/***/ }),
18+
/* 2 */
19+
/***/ (function(module, exports, __webpack_require__) {
20+
21+
module.exports = __webpack_require__.p + "index.html";
22+
23+
/***/ })
24+
]);

test/fixtures/build-font/index.html

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<html>
2+
<head>
3+
<meta charset="utf-8"/>
4+
<title>webfont</title>
5+
<style type="text/css">
6+
*{margin: 0;padding: 0;list-style: none;}
7+
</style>
8+
<script src="./common.js"></script>
9+
<script src="./index.js"></script>
10+
<link href="./index.css" rel="stylesheet" type="text/css" />
11+
</head>
12+
<body>
13+
<h1>webfont 字体预览</h1>
14+
<p class="web-font">英雄不问出路,流氓不看岁数</p>
15+
</body>
16+
</html>

test/fixtures/build-font/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
import './index.less';
2+
import './index.html';

test/fixtures/build-font/index.less

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
@font-face {
2+
font-family: 'webfont';
3+
src: url('webfont.eot');
4+
src: url('webfont.eot?#iefix') format('embedded-opentype'),
5+
url('webfont.woff') format('woff'),
6+
url('webfont.ttf') format('truetype');
7+
}
8+
9+
.web-font{
10+
font-family:"webfont" !important;
11+
font-size:16px;
12+
font-style:normal;
13+
-webkit-font-smoothing: antialiased;
14+
-webkit-text-stroke-width: 0.2px;
15+
-moz-osx-font-smoothing: grayscale;
16+
}

test/fixtures/build-font/package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"entry": {
3+
"index": "./index.js"
4+
}
5+
}

0 commit comments

Comments
 (0)