This repository has been archived on 2023-03-18. You can view files and clone it, but cannot push or open issues or pull requests.
osr-discourse-src/app/assets/javascripts/discourse/lib/discourse-scss.js
Robin Ward 5b02aad9c1
Support for Testem in Ember CLI (#12442)
* DEV: Use custom tags rather than handlebars server side

These will be skipped if they are ever rendered in a document. The
handlebars really messes stuff up.

* DEV: Build our own locale file for testing purposes

We can't practically proxy everything in test mode, but we can
approximate the logic and build our own locale file for testing purposes
that works quite well. This allows us to run tests without a proxy.

* DEV: Support for testem runner for ember cli tests
2021-03-19 09:32:46 -04:00

45 lines
1006 B
JavaScript

const Plugin = require("broccoli-plugin");
const sass = require("sass");
const fs = require("fs");
const concat = require("broccoli-concat");
let built = false;
class DiscourseScss extends Plugin {
constructor(inputNodes, inputFile, options) {
super(inputNodes, {
...options,
persistentOutput: true,
});
this.inputFile = inputFile;
}
build() {
// We could get fancy eventually and do this based on whether the css changes
// but this is just used for tests right now.
if (built) {
return;
}
let file = this.inputPaths[0] + "/" + this.inputFile;
let result = sass.renderSync({
file,
includePaths: this.inputPaths,
});
fs.writeFileSync(
`${this.outputPath}/` + this.inputFile.replace(".scss", ".css"),
result.css
);
built = true;
}
}
module.exports = function scss(path, file) {
return concat(new DiscourseScss([path], file), {
outputFile: `assets/${file.replace(".scss", ".css")}`,
});
};