Hi!
I’m currently working my way on a Django project, and would like to incorporate Node/NPM to my workflow. The primary reason is to allow usage of ES6+
and SASS
on my static files. Anyway, I currently have the following setup:
<project_root>
├── <django_project_root>
│ ├── __init__.py
│ ├── settings.py
│ ├── urls.py
│ ├── views.py
│ └── wsgi.py
├── lib // Compiled stuff.
│ └── app.js
├── LICENSE
├── manage.py
├── package.json
├── README.md
├── requirements.txt
├── src // Uncompiled 'source'
│ └── app.js
├── templates
│ └── index.djt
├── static // What gets referenced in my templates.
│ └── app.js
└── webpack.config.js
Now, I would like to write my JS/SCSS
inside my src
directory, and then:
- Babel do its thing and output an
ES5
friendly version of whatever is insrc
into thelib
folder. - Webpack grabs what’s in
lib
and spits out a browser friendly version into astatic
folder. - Templates inside the
tempaltes
directory loads the contents of thestatic
folder. - Note that I keep both
lib
andstatic
out of version control. Which is correct, since I only need thesrc
file, right?
Anyway, I can successfully do the workflow above with ES6
js files inside src
. But I’m clueless on what to do to do the same with SCSS
files.
Relevant files:
// package.json
{
// ....
"scripts": {
"build": "babel src -d lib && webpack"
},
// ...
}
// webpack.config.js
module.exports = {
entry: './lib/app.js',
output: {
filename: './static/js/app.js',
}
};
How should I continue? Please do tell me if I need to provide more information. Thanks!