Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test local css import in production #43

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,11 @@
"description": "CSS plugin for StealJS",
"main": "css.js",
"scripts": {
"build-1": "node test/css-paths/build.js",
"build-2": "steal-tools build --config test/css-before-js/stealconfig.js --main main --baseUrl test/css-before-js/ --minify false",
"build-3": "node test/css-instantiated/build.js",
"test": "npm run eslint && npm run build-1 && npm run build-2 && npm run build-3 && npm run run-tests",
"test-builds": "node test/create-builds",
"test": "npm run eslint && npm run test-builds && npm run run-tests",
"run-tests": "testee test/test.html --browsers firefox --reporter Spec",
"http-server": "http-server -p 3000 --silent",
"saucelabs": "npm run build-1 && npm run build-2 && npm run build-3 && node test/saucelabs",
"saucelabs": "npm run test-builds && node test/saucelabs",
"document": "bit-docs",
"eslint": "eslint css.js"
},
Expand All @@ -35,10 +33,10 @@
"http-server": "^0.10.0",
"qunitjs": "~2.1.0",
"saucelabs": "^1.4.0",
"steal": "^1.0.0",
"steal": "^1.5.1",
"steal-qunit": "^1.0.0",
"steal-test-helpers": "^0.2.0",
"steal-tools": "^1.0.0",
"steal-tools": "^1.3.3",
"test-saucelabs": "0.0.1",
"testee": "^0.5.0",
"wd": "^1.2.0"
Expand Down
18 changes: 18 additions & 0 deletions test/create-builds.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@

Promise.resolve()
.then(function() {
console.log("creating build for css-paths");
return require("./css-paths/build");
})
.then(function() {
console.log("\ncreating build for css-before-js");
return require("./css-before-js/build");
})
.then(function() {
console.log("\ncreating build for css-instantiated");
return require("./css-instantiated/build");
})
.then(function() {
console.log("\ncreating build for css-local-import");
return require("./css-local-import/build");
});
9 changes: 9 additions & 0 deletions test/css-before-js/build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
var path = require("path");
var stealTools = require("steal-tools");

module.exports = stealTools.build({
main: "main",
config: path.join(__dirname, "stealconfig.js")
}, {
minify: false
});
4 changes: 2 additions & 2 deletions test/css-instantiated/build.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
var stealTools = require("steal-tools");

var promise = stealTools.build({
module.exports = stealTools.build({
main: "main",
config: __dirname+"/stealconfig.js"
},{
minify: false,
debug: true
});
});
8 changes: 8 additions & 0 deletions test/css-local-import/build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
var path = require("path");
var stealTools = require("steal-tools");

module.exports = stealTools.build({
main: "main",
config: path.join(__dirname, "stealconfig.js")
}, {
});
3 changes: 3 additions & 0 deletions test/css-local-import/foo.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
p {
font-size: 30px;
}
5 changes: 5 additions & 0 deletions test/css-local-import/main.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
@import url("foo.css");

body {
padding-top: 50px;
}
12 changes: 12 additions & 0 deletions test/css-local-import/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
require("./main.css");

var p = document.getElementsByTagName("p").item(0);
var s = getComputedStyle(p);

if (window.assert) {
assert.equal(s.fontSize, "30px", "should load the @import");
done();
}
else {
console.log("fontSize: ", s.fontSize);
}
22 changes: 22 additions & 0 deletions test/css-local-import/prod.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>css local @import</title>
</head>
<body>
<script>
window.done = window.parent.done;
window.assert = window.parent.assert;
</script>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer nec odio.
Praesent libero. Sed cursus ante dapibus diam. Sed nisi. Nulla quis sem at
nibh elementum imperdiet. Duis sagittis ipsum. Praesent mauris. Fusce nec
tellus sed augue semper porta. Mauris massa. Vestibulum lacinia arcu eget
nulla. Class aptent taciti sociosqu ad litora torquent per conubia nostra,
per inceptos himenaeos.
</p>
<script src="./dist/steal.production.js"></script>
</body>
</html>
11 changes: 11 additions & 0 deletions test/css-local-import/stealconfig.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
steal.config({
ext: {
"css": "steal-css"
},
paths: {
"steal-css": "../../css.js"
},
cssOptions: {
timeout: '15'
}
});
4 changes: 2 additions & 2 deletions test/css-paths/build.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
var stealTools = require("steal-tools");

var promise = stealTools.build({
module.exports = stealTools.build({
main: "main",
config: __dirname+"/config.js"
},{
minify: false,
debug: true,
bundleAssets: true
});
});
2 changes: 1 addition & 1 deletion test/css-paths/folder/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
}
#test-relative {
background-image: url("locate://bootstrap/other.png");
}
}
6 changes: 5 additions & 1 deletion test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,9 @@ QUnit.test("css files starting with attribute selectors work", function(assert)
});

QUnit.test("should handle IE8/9 stylesheet limit", function(assert) {
makeIframe("ie-stylesheet-limit/dev.html", assert)
makeIframe("ie-stylesheet-limit/dev.html", assert);
});

QUnit.test("local @import should work in production", function(assert) {
makeIframe("css-local-import/prod.html", assert);
});