NativeScript / nativescript-dev-sass

SASS CSS pre-processor for NativeScript projects
Apache License 2.0
44 stars 17 forks source link

bug: Throws an error if scss-file is empty #10

Closed m-abs closed 8 years ago

m-abs commented 8 years ago

We have a number of empty files in our project and we got this error when we tried to move to sass

TypeError: Cannot read property 'css' of undefined
    at /home/mabs/project/LYT3/nativescript/node_modules/nativescript-dev-sass/lib/converter.js:74:39
    at Object.module.exports.render (/home/mabs/project/LYT3/nativescript/node_modules/nativescript-dev-sass/node_modules/node-sass/lib/index.js:376:5)
    at parseSass (/home/mabs/project/LYT3/nativescript/node_modules/nativescript-dev-sass/lib/converter.js:58:8)
    at loopSassFilesAsync (/home/mabs/project/LYT3/nativescript/node_modules/nativescript-dev-sass/lib/converter.js:32:9)
    at /home/mabs/project/LYT3/nativescript/node_modules/nativescript-dev-sass/lib/converter.js:41:13
    at /home/mabs/project/LYT3/nativescript/node_modules/nativescript-dev-sass/lib/converter.js:76:9
    at /home/mabs/.nvm/versions/node/v6.5.0/lib/node_modules/nativescript/node_modules/npm/node_modules/graceful-fs/graceful-fs.js:99:16
    at /home/mabs/.nvm/versions/node/v6.5.0/lib/node_modules/nativescript/node_modules/npm/node_modules/graceful-fs/graceful-fs.js:43:10
    at FSReqWrap.oncomplete (fs.js:123:15)

The problem is that the var output in nativescript-dev-sass/lib/converter.js:32 is undefined, but you only check for null

I've made a temporary fix in our end, by adding dummy css to all the files. (our setup doesn't allow removal of the files)

jacobedawson commented 8 years ago

This is exactly the problem that I encountered over the past 3 days (I'm new to NativeScript). The error is very cryptic and led to a couple of hours of adding & remove folders & files trying to identify the issue.

Like @m-abs suggested, even something as simple as placing a random comment at the top of the .scss / .sass file solves this problem:

/* comment */

I'm sure a lot of newcomers to NativeScript (especially those coming from the web with heavy usage of Sass) are going to run across this issue...