diff --git a/.travis.yml b/.travis.yml index ef8d75c..bee776c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,6 +3,10 @@ sudo: false language: node_js node_js: - "lts/*" +addons: + apt: + packages: + - sassc script: - make - make po/starter-kit.pot diff --git a/package.json b/package.json index e6fafc9..b197446 100644 --- a/package.json +++ b/package.json @@ -36,10 +36,8 @@ "htmlparser": "^1.7.7", "jed": "^1.1.1", "mini-css-extract-plugin": "^0.11.0", - "node-sass": "^4.14.1", "po2json": "^1.0.0-alpha", "qunit": "^2.9.3", - "sass-loader": "^10.0.2", "sizzle": "^2.3.3", "stdio": "^2.1.0", "string-replace-loader": "^2.3.0", diff --git a/src/lib/sassc-loader.js b/src/lib/sassc-loader.js new file mode 100644 index 0000000..19ff806 --- /dev/null +++ b/src/lib/sassc-loader.js @@ -0,0 +1,25 @@ +const fs = require('fs'); +const path = require('path'); +const childProcess = require('child_process'); + +/* source is not used. This must be the first loader in the chain, using this.resource, so that sassc can include the scss file's directory in the include path */ +module.exports = function() { + this.cacheable(); + + const workdir = fs.mkdtempSync("sassc-loader."); + const out = path.join(workdir, "output.css"); + + childProcess.execFileSync( + 'sassc', + ['--load-path=node_modules', '--style=compressed', '--sourcemap', this.resource, out], + { stdio: ['pipe', 'stdio', 'stdio'] }); + + const css = fs.readFileSync(out, 'utf8'); + const cssmap = fs.readFileSync(out + ".map", 'utf8'); + + fs.unlinkSync(out); + fs.unlinkSync(out + ".map"); + fs.rmdirSync(workdir); + + this.callback(null, css, cssmap); +}; diff --git a/webpack.config.js b/webpack.config.js index a0d9904..386ea37 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -118,6 +118,9 @@ module.exports = { resolve: { modules: [ nodedir ], }, + resolveLoader: { + modules: [ nodedir, path.resolve(__dirname, 'src/lib') ], + }, watchOptions: { ignored: /node_modules/, }, @@ -165,15 +168,7 @@ module.exports = { ] }, }, - { - loader: 'sass-loader', - options: { - sassOptions: { - outputStyle: 'compressed', - }, - sourceMap: true, - }, - }, + 'sassc-loader', ] }, { @@ -188,15 +183,7 @@ module.exports = { url: false } }, - { - loader: 'sass-loader', - options: { - sassOptions: { - outputStyle: 'compressed', - }, - sourceMap: true, - }, - }, + 'sassc-loader', ] }, ]