Skip to content
Draft
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
25 changes: 17 additions & 8 deletions styles/build/build.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,18 @@ void main(List<String> arguments) {
throw Exception('Input argument not given.');
}

var inputFile = arguments[0];
var outputFile = arguments[1];

var inputFilePath = arguments[0];
var outputFilePath = arguments[1];
var stylesPath = "${Directory.current.path}/styles/";
var styleName = inputFilePath.split('/')[3];

if (File(stylesPath).existsSync()) {
throw Exception('Cannot find styles root directory.');
}

sass.Callable toDataUri = new sass.Callable.function('toDataUri', r'$type, $path', (arguments) {
var pathString = arguments[1].toString().replaceAll('"', '');
var typeString = arguments[0].toString().replaceAll('"', '');
var pathString = arguments[1].toString().replaceAll('"', '');
var fileData = File("${stylesPath}${pathString}").readAsBytesSync();
var encoded = base64Encode(fileData);
var dataUri = "data:image/${typeString};base64,${encoded}";
Expand All @@ -27,17 +28,25 @@ void main(List<String> arguments) {

var startTime = DateTime.now();
var result = sass.compileToResult(
inputFile,
inputFilePath,
loadPaths: {stylesPath},
sourceMap: true,
functions: [toDataUri]
);
var endTime = DateTime.now();
print("compile time is: ${endTime.difference(startTime)}");

if ((result.css.length > 0) & (outputFile.length > 0)) {
new File(outputFile).writeAsStringSync(result.css);
new File("${outputFile}.map").writeAsStringSync(json.encode(result.sourceMap.toJson()));
if ((result.css.length > 0) & (outputFilePath.length > 0)) {
var outputFile = new File(outputFilePath);
outputFile.writeAsStringSync(result.css);
// Replace all absolute mapping paths with relative
var map_json = result.sourceMap.toJson();
map_json['sources'] = result.sourceMap.urls.map(
(path) => path.replaceFirst("file:///code/styles", "../build/..")
).toList();
// Write map file & append map path to css
new File("${outputFilePath}.map").writeAsStringSync(json.encode(map_json));
outputFile.writeAsStringSync("\n/*# sourceMappingURL=${styleName}-pdf.css.map */\n", mode: FileMode.append);
} else {
throw Exception("Empty output");
}
Expand Down
3 changes: 2 additions & 1 deletion styles/output/accounting-pdf.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion styles/output/american-government-pdf.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion styles/output/anatomy-pdf.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion styles/output/anthropology-pdf.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion styles/output/ap-biology-pdf.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion styles/output/ap-physics-2e-pdf.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion styles/output/ap-physics-pdf.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion styles/output/astronomy-pdf.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion styles/output/bca-pdf.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion styles/output/biology-pdf.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion styles/output/business-ethics-pdf.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion styles/output/calculus-pdf.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion styles/output/chemistry-pdf.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion styles/output/college-physics-2e-pdf.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion styles/output/college-physics-pdf.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion styles/output/college-success-pdf.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion styles/output/computer-science-pdf.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion styles/output/contemporary-math-pdf.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion styles/output/dev-math-pdf.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion styles/output/economics-pdf.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion styles/output/english-composition-pdf.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion styles/output/entrepreneurship-pdf.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion styles/output/finance-pdf.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion styles/output/history-pdf.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion styles/output/hs-college-success-pdf.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion styles/output/hs-physics-pdf.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion styles/output/intro-business-pdf.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion styles/output/marketing-pdf.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion styles/output/microbiology-pdf.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion styles/output/nursing-external-pdf.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion styles/output/nursing-internal-pdf.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion styles/output/organic-chemistry-pdf.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion styles/output/philosophy-pdf.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion styles/output/pl-economics-pdf.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion styles/output/pl-psychology-pdf.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion styles/output/pl-u-physics-pdf.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion styles/output/political-science-pdf.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion styles/output/precalculus-coreq-pdf.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion styles/output/precalculus-pdf.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion styles/output/principles-management-pdf.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion styles/output/psychology-pdf.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion styles/output/python-pdf.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion styles/output/sociology-pdf.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading