Skip to content

Commit 9b9af87

Browse files
committed
Add manual test for correct source maps
1 parent 54b17b4 commit 9b9af87

File tree

6 files changed

+53
-11
lines changed

6 files changed

+53
-11
lines changed

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,16 @@
44
"author": "Tobias Koppers @sokra",
55
"description": "less loader module for webpack",
66
"scripts": {
7-
"test": "mocha -R spec"
7+
"test": "mocha -R spec",
8+
"test-source-map": "webpack --config test/sourceMap/webpack.config.js && open ./test/sourceMap/index.html"
89
},
910
"peerDependencies": {
1011
"less": "^2.3.1"
1112
},
1213
"devDependencies": {
14+
"css-loader": "^0.9.1",
1315
"enhanced-require": "^0.5.0-beta6",
16+
"extract-text-webpack-plugin": "^0.3.8",
1417
"less": "^2.3.1",
1518
"mocha": "^2.0.1",
1619
"raw-loader": "^0.5.1",

test/css/source-map.css

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
1-
.box {
2-
color: #fe33ac;
3-
border-color: #fdcdea;
4-
background: url(box.png);
5-
}
6-
.box div {
7-
-webkit-box-shadow: 0 0 5px rgba(0, 0, 0, 0.3);
8-
box-shadow: 0 0 5px rgba(0, 0, 0, 0.3);
1+
.modules-dir-some-module,
2+
#it-works {
3+
color: hotpink;
94
}
105
#it-works {
116
margin: 10px;

test/less/source-map.less

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
@import "basic";
1+
// Should usually be imported with '~' but since our test setup for this is complicated, we don't use it here
2+
@import "../bower_components/some/module";
23

3-
#it-works {
4+
#it-works:extend(.modules-dir-some-module) {
45
margin: 10px;
56
}

test/sourceMap/entry.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
"use strict";
2+
3+
require("../less/source-map.less");

test/sourceMap/index.html

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title></title>
5+
<meta charset="utf-8"/>
6+
<link href="../output/styles.css" type="text/css" rel="stylesheet">
7+
</head>
8+
<body class="modules-dir-some-module">
9+
<h1 id="it-works">Open the developer tools, dude!</h1>
10+
</body>
11+
</html>

test/sourceMap/webpack.config.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
"use strict";
2+
3+
var path = require("path");
4+
var ExtractTextPlugin = require("extract-text-webpack-plugin");
5+
6+
var pathToLessLoader = path.resolve(__dirname, "../../index.js");
7+
8+
module.exports = {
9+
entry: path.resolve(__dirname, "./entry.js"),
10+
output: {
11+
path: path.resolve(__dirname, "../output"),
12+
filename: "bundle.sourcemap.js"
13+
},
14+
devtool: "inline-source-map",
15+
module: {
16+
loaders: [
17+
{
18+
test: /\.less/,
19+
loader: ExtractTextPlugin.extract(
20+
"css-loader?sourceMap!" +
21+
pathToLessLoader + "?sourceMap"
22+
)
23+
}
24+
]
25+
},
26+
plugins: [
27+
new ExtractTextPlugin("styles.css")
28+
]
29+
};

0 commit comments

Comments
 (0)