Active
Project:
Neato
Version:
8.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Reporter:
Created:
24 Jun 2015 at 19:15 UTC
Updated:
17 May 2016 at 08:35 UTC
Jump to comment: Most recent, Most recent file
After creating a neato subtheme and starting to work on the javascript I noticed that the JS files get minified as a result of the Gulp compress task.
Create a new folder for the javascript source files (as scss is for css) where the javascript sources will live. Update the Gulpfile's task to watch the source folder and to use the js folder as only the destination for minimized scripts.
Create patch for above functionality.
n/a
n/a
Javascript will now live in a source folder and will be minimized / compressed into the js folder.
| Comment | File | Size | Author |
|---|---|---|---|
| #12 | neatojs.png | 8.3 KB | achton |
| #7 | javascript_doesn_t_have-2511612-7.patch | 335 bytes | dasginganinja |
| #1 | javascript_doesn_t_have-2511612-1.patch | 1.04 KB | dasginganinja |
Comments
Comment #1
dasginganinjaPatch is attached for this functionality.
Comment #2
kevinquillen commentedComment #5
kevinquillen commentedComment #6
dasginganinjaKevin, I just noticed that you had the js-src folder inside of the js folder. With the patch I submitted the js-src folder was at the root, i.e. (css, scss, js, js-src).
This is broken on the current releases of both the 7.x and 8.x.
Comment #7
dasginganinja7.x & 8.x fix to move folders to intended location
Comment #8
dasginganinjaComment #9
dasginganinjaI created the scripts.js in the JS folder so the generated file exists. This way in case we want to add the scripts to the .info file the file will be there. I do see that the 8.x version has scripts.js loading so we should probably create a patch to have the 7.x version have the same functionality.
Comment #10
kevinquillen commentedHow about we rename the directory to just 'src'? js-src is redundant.
Comment #11
dasginganinjaAlright how about we do it src/js and src/scss if that's the case. Anything that gets preprocessed should live in the src folder if that's the case.
Comment #12
achtonI don't think minifed JS has the same relation to the source JS as CSS has to SCSS. I like the way the folder structure is out of the box right now:

I think the source JS should simply reside in the
/jsfolder, and the minified JS should simply be generated in the theme root. Storing the files you really want to edit in the subdirectory of a subdirectory makes it more difficult to find.Comment #13
kevinquillen commentedachton, what happens in the event you want to add JS plugins to the theme? It would seem that load order takes precedent, and I am not sure if the minifier would be able to intelligently bundle them up to not prevent error.
With something like js/src, custom scripts can be minified, while external plugins would remain untouched by just being in js folder.
Comment #14
achton@kevin - I guess an option could be to require libraries to be named
*.min.js, and then make the Gulp compress task omit those files from the js folder.Another option would be to have to same-level JS folders:
jsandjs-src. I find it cumbersome to have the actual JS source two levels deep, and the minified JS (which you never touch with your editor) in the upper folder level.Comment #15
kevinquillen commentedShould we name the output folder js-min, then?
Comment #16
kevinquillen commentedMarking up for 8.x - resulting change will be backported to 7.x
Comment #17
kevinquillen commentedWhat if we changed the js folder structure to:
With min being the output of src, vendor for any plugins?
Comment #18
finex commentedCurrently the neato starter kit already has two directories on the same level for the CSS ("scss" and "css"). Why don't do the same for JS with "js" and "js-src"?
About the 3rd-party plugins I suggest to keep them separated from the custom code.
For example on the current project I'm working to with neato theme I've collected all the plugins on the libraries subdirectory and the source code looks quite clean.
The minifier shouldn't care about the 3rd-party plugins which are usually shipped with a .min version.
On the themename.libraries.yml you can add all the JS (custom and 3rd-party) on the desired order. Example:
If the css folder is separated from the scss, the same system should be used for the JS files. I prefer one less directory to dig :-)