This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 237600 - SASS preprocessor does not work if sass is not in web root
Summary: SASS preprocessor does not work if sass is not in web root
Status: REOPENED
Alias: None
Product: web
Classification: Unclassified
Component: CSS Preprocessors (SASS, LESS, ...) (show other bugs)
Version: 7.4
Hardware: All All
: P4 normal with 3 votes (vote)
Assignee: Tomas Mysik
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-10-24 08:25 UTC by rafy
Modified: 2015-08-24 05:32 UTC (History)
2 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
sample project (3.02 KB, application/zip)
2014-01-02 08:42 UTC, Vladimir Riha
Details
Java Maven Application and Sass file (2.35 KB, application/zip)
2015-06-30 11:32 UTC, apokarlypse
Details

Note You need to log in before you can comment on or make changes to this bug.
Description rafy 2013-10-24 08:25:02 UTC
When the sass files are not within the web-root they are not being compiled. This is an error as the sass-files do not have to be accessible for the end-user/web-user.
 
The Directory strucuture:

/sass - Sass Files
/web - web-root
/web/css - CSS-Files

Project Settings: 
Web root: web
Sass input: /sass, Sass output: /web/css

Log Message:

INFO [org.netbeans.modules.css.prep.process.BaseProcessor]: Not compiling, file V:\Project\sass\global.scss not underneath web root of project V:\Project
Comment 1 Vladimir Riha 2013-10-29 07:34:44 UTC
Thank you for reporting. I've tried to set the mapping like 

"../sass" -> /css  (afaik path must be site root relative)

but it didn't work either and log says

INFO [CPOnSaveHook]: processSavedFile called for Sass type on project /home/vriha/NetBeansProjects/HTML5Application36.


Product Version: NetBeans IDE Dev (Build 201310290001)
Java: 1.7.0_45; Java HotSpot(TM) Client VM 24.45-b08
Runtime: Java(TM) SE Runtime Environment 1.7.0_45-b18
System: Linux version 3.2.0-48-generic-pae running on i386; UTF-8; en_US (nb)
Comment 2 Vladimir Riha 2013-10-29 07:36:19 UTC
Adding Tomas to cc as it seems to be issue with Sass/less compilers
Comment 3 wizhippo 2013-12-03 19:32:05 UTC
I have the same issue as  want to use compass with sass and a custom config.rb.  It looks like sass is run from the webroot and not from the project root.
Comment 4 Tomas Mysik 2013-12-03 19:33:15 UTC
(In reply to wizhippo from comment #3)
> It looks like sass is run from the webroot and not from the
> project root.

Yes, that is true.
Comment 5 wizhippo 2013-12-03 21:22:23 UTC
(In reply to Tomas Mysik from comment #4)
> (In reply to wizhippo from comment #3)
> > It looks like sass is run from the webroot and not from the
> > project root.
> 
> Yes, that is true.

I mention this because if you want your config.rb to be in the project root instead of the webroot you can't as it won't be found by sass.

It would be nice if you could specify what directory the sass command runs from.  That would allow directory structures where the sass source does not reside in the webroot.
Comment 6 Tomas Mysik 2013-12-03 21:27:52 UTC
(In reply to wizhippo from comment #5)
> It would be nice if you could specify what directory the sass command runs
> from.  That would allow directory structures where the sass source does not
> reside in the webroot.

This could be doable, I think. The default would be webroot. Would it make sense to allow to select any project directory or just: webroot and project directory?

Thanks.
Comment 7 Tomas Mysik 2013-12-04 08:19:46 UTC
(In reply to Tomas Mysik from comment #6)
> just: webroot and project directory?

BTW I would prefer this option.

Thanks.
Comment 8 wizhippo 2013-12-04 14:22:05 UTC
> > just: webroot and project directory?
> 
> BTW I would prefer this option.
> 
> Thanks.

This would work for my needs.

I believe limiting it to any folder within and including the project folder would be best, as others could have some other way they layout their project where they do no like cluttering the root folder with configs.

It would be bad practice to allow it on any directory on the file system as when sharing the project the folder may not exist.
Comment 9 Tomas Mysik 2013-12-05 10:58:25 UTC
Sorry, I was too fast, this is definitely not a minor change. CSS preprocessors are designed to work in web root so this represents quite a lot of changes. In any case, this is not a defect but an enhancement.

Thanks for reporting.
Comment 10 rafy 2013-12-18 17:10:17 UTC
I can see that it is not easy to fix, but that makes it no less of a bug.

It is really not required to have sass files in your web dir and all the default sass tools (command line and compass) are totally unaware of the fact whether it is running within a web dir or not (how should they know). It is quite annoying that my colleague with another IDE is able to compile SASS files and I have to start compass every time I start developing. 

Any directory within the project directory should be selectable for input and output.
Comment 11 Tomas Mysik 2013-12-19 06:39:12 UTC
Well, in fact, since this functionality works as designed, it cannot be a defect. But I understand that it is annoying so I will try to have a look at it. The ugly solution could be to allow "../" for mapping - not nice but should work ;)

Thanks.
Comment 12 Tomas Mysik 2013-12-19 08:33:50 UTC
So, should be done I hope. Please note that this is "unofficial" feature so use it on your own risk :)

Simply add e.g. this mapping:

../scss -> /css

All the mapping paths are still resolved to the web root directory so there should not be any regressions (web root remains working directory as well). Láďo, also please test scenarios like deleting scss/less file, renaming it etc.

Thanks.

http://hg.netbeans.org/web-main/rev/b4a8554593f8
Comment 13 Vladimir Riha 2014-01-02 08:41:33 UTC
It doesn't work for me, I'll attach my project for reference:
 - mapping is ../pokus -> /css
 - once I save file ../pokus/soubor.scss, css is not created
Comment 14 Vladimir Riha 2014-01-02 08:42:04 UTC
Created attachment 143559 [details]
sample project

tested in

Product Version: NetBeans IDE Dev (Build web-main-274-on-20140102)
Java: 1.7.0_45; Java HotSpot(TM) Client VM 24.45-b08
Runtime: Java(TM) SE Runtime Environment 1.7.0_45-b18
System: Linux version 3.2.0-48-generic-pae running on i386; UTF-8; en_US (nb)
Comment 15 Tomas Mysik 2014-01-02 09:23:43 UTC
The reason is simple - HTML5 project does not listen on project directory but only on site root. I am not going to change/fix this, there should be complications. Moreover, in the Projects view, only Site Root is visible so it will not be a common case to have directories outside of these folder and access them via Files view I hope... However, it should work without any project in the PHP projects.

Thanks.
Comment 16 Vladimir Riha 2014-01-02 10:04:07 UTC
Thanks, I agree. Tested in PHP project and it works fine, when manipulating with source scss file, target css is e.g. moved/renamed etc. accordingly, mapping works in both web root and outside of web root.


Product Version: NetBeans IDE Dev (Build 201401020002)
Java: 1.7.0_45; Java HotSpot(TM) Client VM 24.45-b08
Runtime: Java(TM) SE Runtime Environment 1.7.0_45-b18
System: Linux version 3.2.0-48-generic-pae running on i386; UTF-8; en_US (nb)
Comment 17 apokarlypse 2015-06-30 07:55:30 UTC
Normally I would agree that you don’t need another folder.
But in my case I am not using a PHP/Web Project in Netbeans. I am using a Java Spring Web Application and in this case you cannot preprocess SASS/LESS in Netbeans because there is not web.root.
Comment 18 Tomas Mysik 2015-06-30 08:41:59 UTC
(In reply to apokarlypse from comment #17)
> I am using a
> Java Spring Web Application and in this case you cannot preprocess SASS/LESS
> in Netbeans because there is not web.root.

@apokarlypse: What project type is it exactly? Please attach a sample project so we can investigate it.

Thanks.
Comment 19 apokarlypse 2015-06-30 11:32:02 UTC
Created attachment 154440 [details]
Java Maven Application and Sass file

When I add a .scss file to my project and save it, Netbeans asks if it should enable auto Sass Preprocessing, when I accept this it makes a nb-configuration.xml in which the Sass config is saved.
I changed this config to show that alternative paths does not work either.
Comment 20 Tomas Mysik 2015-06-30 12:18:56 UTC
(In reply to apokarlypse from comment #19)
> Created attachment 154440 [details]
> Java Maven Application and Sass file

Your project is Java SE project but you need to create Web project (New Project > Maven > Web Application).
Comment 21 apokarlypse 2015-06-30 12:41:54 UTC
That is not a solution if i NEED a Java Application. For example: Spring Boot needs a Java Maven Project and has all its sources in the resources directory.
This is not the only Framework that works like that..
Comment 22 Tomas Mysik 2015-06-30 13:28:44 UTC
(In reply to apokarlypse from comment #21)
> That is not a solution if i NEED a Java Application.

In such case, feel free to submit an enhancement. Thanks.
Comment 23 CyRaid 2015-08-23 02:41:25 UTC
I also can't seem to get SASS CSS Preprocessors to work.  Works when I make a PHP Project, but not on an HTML5 project.  Sorry, but I'd rather not have my users view my SCSS files, or add complexity by adding to my grunt and setting up a watch to convert CSS files. If you refuse to change it, why don't you at least add an 'onsave->grunt' action?
Comment 24 Tomas Mysik 2015-08-24 05:32:33 UTC
(In reply to CyRaid from comment #23)
> If you refuse to change it, why
> don't you at least add an 'onsave->grunt' action?

Good idea, reported as issue #254632.

Thanks for reporting.