Reputation: 1004
Not sure if this is the right place to ask this, so please bear with me.
I'm quite new to build systems/ front end workflow and have relied heavily on IDE built in systems to do the work for me such as compiling Sass to css.
I recently discovered the world of npm gulp and now need to get a project working and compiled from a "dev" folder to a "build" folder.
Upvotes: 1
Views: 515
Reputation: 573
I would set it up this way, use the app folder for development purposes, while the dist (as in "distribution") folder is used to contain optimized files for the production site.
Since app is used for development purposes, all your code will be placed in app and will compile in the dist folder when you run something like gulp build
|- app/
|- css/
|- fonts/
|- images/
|- index.html
|- js/
|- scss/
|- dist/
|- gulpfile.js
|- node_modules/
|- package.json
Upvotes: 0
Reputation: 14564
For most front-end build systems, your node_modules folder actually sits at the root of your project folder. Your dev
folder (i.e. where you put your source code) which is a sub-folder of your project root, will then be able to see npm modules installed into the project root folder.
Note that in many front-end setups I've seen, the convention is to call that dev
folder src
instead.
Upvotes: 0
Reputation: 7333
This works with the way node resolve modules. If you install a module like gulp
, you will have a structure similar to this:
- node_modules/
- gulp/
...
- src/
index.js
gulpfile.js
In order to import gulp
into your script, you can just use require('gulp')
(or import gulp from 'gulp'
if you are using EcmaScript6) and node will find out where to look for this module.
You can do it both from the gulpfile.js
or from src/index.js
. Node will try to find the node_modules
folder in the script folder, or in any parent folder.
Upvotes: 1