Skip to content

Commit 0e518d3

Browse files
author
尹曰
committed
Add tests for Sass loader
1 parent 6d76f7a commit 0e518d3

File tree

16 files changed

+238
-0
lines changed

16 files changed

+238
-0
lines changed

test/build-spec.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,16 @@ describe('lib/build.js', function() {
217217
assert(dest, 'require-less-extract');
218218
});
219219

220+
it('require sass extract', function*() {
221+
yield build({
222+
debug: true,
223+
cwd: join(fixtures, 'require-sass'),
224+
dest: dest,
225+
extractCSS: true
226+
});
227+
assert(dest, 'require-sass-extract');
228+
});
229+
220230
it('jsx', function*() {
221231
yield build({
222232
debug: true,
@@ -396,6 +406,30 @@ describe('lib/build.js', function() {
396406

397407
});
398408

409+
describe('custom-loader-sass', function() {
410+
411+
var oldCwd;
412+
413+
before(function() {
414+
oldCwd = process.cwd();
415+
process.chdir(join(fixtures, 'custom-loader-sass'));
416+
});
417+
418+
after(function() {
419+
process.chdir(oldCwd);
420+
});
421+
422+
it('custom-loader-sass', function*() {
423+
yield build({
424+
debug: true,
425+
cwd: join(fixtures, 'custom-loader-sass'),
426+
dest: dest
427+
});
428+
assert(dest, 'custom-loader-sass');
429+
});
430+
431+
});
432+
399433
describe('scripts', function() {
400434

401435
afterEach(function() {

test/expected/custom-loader-sass/a.css

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

test/expected/custom-loader-sass/a.js

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
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 = "";
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__(2);
48+
49+
50+
/***/ },
51+
/* 1 */
52+
/***/ function(module, exports) {
53+
54+
// removed by extract-text-webpack-plugin
55+
56+
/***/ },
57+
/* 2 */
58+
/***/ function(module, exports, __webpack_require__) {
59+
60+
__webpack_require__(1);
61+
console.log(1);
62+
63+
64+
65+
/***/ }
66+
/******/ ]);

test/expected/require-sass-extract/a.css

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
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 = "";
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__(2);
48+
49+
50+
/***/ },
51+
/* 1 */
52+
/***/ function(module, exports) {
53+
54+
// removed by extract-text-webpack-plugin
55+
56+
/***/ },
57+
/* 2 */
58+
/***/ function(module, exports, __webpack_require__) {
59+
60+
61+
__webpack_require__(1);
62+
console.log(1);
63+
64+
65+
/***/ }
66+
/******/ ]);
261 KB
Loading

test/fixtures/custom-loader-sass/a.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
require('./a.scss');
2+
console.log(1);
3+
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
¥color: #121212;
3+
4+
a {
5+
color: ¥color;
6+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
'use strict';
2+
3+
module.exports = function(source) {
4+
this.cacheable && this.cacheable();
5+
return source
6+
.replace(//g, '$');
7+
};
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"spm": {
3+
"output": ["a.js"],
4+
"build": {
5+
"loader": {
6+
".scss": "+./foo$"
7+
},
8+
"extractCSS": true
9+
}
10+
}
11+
}

0 commit comments

Comments
 (0)