Cookiecutter-django: Use webpack to compile scss/sass to css and add babel support

Created on 1 May 2017  ยท  7Comments  ยท  Source: pydanny/cookiecutter-django

I am using cookiecutter-django with webpack and it's working nicely. I only have to keep running webpack on watch mode and everything else just works. Can I propose the change? It uses npm scripts instead of grunt.

needs further review

Most helpful comment

I have built a very simple integration with Webpack and it works in a very basic setup. It's my first time contributing, forgive me for the incomplete project. https://github.com/kiran-capoor94/cookiecutter-django-webpack

All 7 comments

@geekodour, for historical reference on webpack support, see #774

Inclusion of a light Webpack setup would be nice, but it would have to be easily maintainable for us.

I'll just post my folder structure webpack included here, not sure if it's good bad. it's probably bad. (did not show .babelrc)

.
โ”œโ”€โ”€ contrib
โ”œโ”€โ”€ __init__.py
โ”œโ”€โ”€ media
โ”œโ”€โ”€ node_modules <--
โ”œโ”€โ”€ package.json <--
โ”œโ”€โ”€ postcss.config.js <--
โ”œโ”€โ”€ __pycache__
โ”œโ”€โ”€ static
โ”œโ”€โ”€ taskapp
โ”œโ”€โ”€ templates
โ”œโ”€โ”€ users
โ”œโ”€โ”€ videos (app)
โ”œโ”€โ”€ vlog (app)
โ””โ”€โ”€ webpack.config.js <--

inside static

.
โ”œโ”€โ”€ fonts
โ”œโ”€โ”€ images
โ”‚ย ย  โ””โ”€โ”€ favicon.ico
โ”œโ”€โ”€ js
โ”‚ย ย  โ””โ”€โ”€ project.js
โ”œโ”€โ”€ public
โ”‚ย ย  โ”œโ”€โ”€ Main.css
โ”‚ย ย  โ””โ”€โ”€ Main.js
โ”œโ”€โ”€ sass
โ”‚ย ย  โ””โ”€โ”€ project.sass
โ””โ”€โ”€ vendor
    โ”œโ”€โ”€ responsive-nav.css
    โ””โ”€โ”€ responsive-nav.min.js

the project.js in /js @imports project.sass from /sass and I am using webpack extractTextPlugin to put the Main.css and Main.js into /public

@geekodour

Is webpack worth using in a multiple page application?

I have never used webpack in practice but I read articles mainly about how cool it is :smile: and also how to use it to optimize the delivery of static content in a single page application. I understood the benefits there but what about a traditional Django app?

Well I have problems currently including Vue.js plugins without Webpack... It would be awesome if I could have just spun up Webpack for this.

Just throwing this out there: I use https://github.com/owais/django-webpack-loader for managing webpack inside of Django, which is a really solid solution overall.

I have built a very simple integration with Webpack and it works in a very basic setup. It's my first time contributing, forgive me for the incomplete project. https://github.com/kiran-capoor94/cookiecutter-django-webpack

Was this page helpful?
0 / 5 - 0 ratings

Related issues

huydbui picture huydbui  ยท  3Comments

pygabo picture pygabo  ยท  3Comments

sebastian-code picture sebastian-code  ยท  4Comments

jsmedmar picture jsmedmar  ยท  3Comments

japrogramer picture japrogramer  ยท  4Comments