How can I use django-pipeline for JSX with browserify? - django

I am setting up the asset pipeline for a new project. We already use React.js along with webpack in a gulp-based build system and would like to use React for the new project as well. Now, since the application is written in django, I would like to port the pipeline to django-pipeline.
Ok, I can replace webpack with pipeline-browserify, and there's also PyReact for jsx compiling. But I am unable to pipe my jsx files first through the JSX compiler and then to browserify. As far as I can tell, there is just a single compiler stage with django-pipeline. Or am I missing something? Please tell me I'm wrong...
Thanks!

My quick way for dealing with this was just to also use the reactify plugin for browserify and adding PIPELINE_BROWSERIFY_ARGUMENTS = '-t reactify' to my Django settings.
Django-pipeline does support putting multiple compilers, though in my particular case, since I've used browserify more than django-pipeline, I used the single browserify compiler instead.

Related

Using Sass with Django

Im looking for a reasonably simple toolset and workflow for incorporating Sass into my Django projects. Im predominantly backend focused and have just started investigating Sass, so bear with me.
My initial idea was to keep things simple by just using node-sass without trying to incorporate Gulp, django-pipeline or anything else initially.
My Django apps are usually structured such that I create a static/app/css folder in each app. One option I guess would be to now create an additional folder per app for scss files, ie: static/app/scss. The problem there would be that when running collectstatic in production, the scss files will be gathered as well. So should the scss files for each app be kept somewhere else? (I guess it doesn't really matter if the scss files are included when collectstatic runs?)
Next, outside of my Django project folders I would create a folder to install node-sass since I wouldn't want to install it globally and I don't want the node-modules folder inside my Django project or inside source control.
I guess the node-modules folder can be thought of like using a python virtualenv instead of installing packages globally?
Next, inside my Django project somewhere (not sure where?) I would have the package.json file containing a scripts section for every scss file I want compiled to css, eg:
"scripts": {
"compile:sass": "node-sass app1/static/app1/scss/style.scss app1/static/app1/css/style.css",
"compile:sass": "node-sass app2/static/app2/scss/style.scss app2/static/app2/css/style.css",
"compile:sass": "node-sass app3/static/app3/scss/style.scss app3/static/app3/css/style.css"
}
Lastly, I would just run compile:sass with the watch flag to constantly compile any files I work on and put them in the correct folders.
So my questions are, is the above setup a good approach (at least initially if im not ready to add yet another tool like Gulp etc to the mix)?
Also, how will I run compile:sass considering my package.json file will be in the Django project somewhere and the node-modules folder containing the node-sass installation will be somewhere else.
I help maintain node-sass, so I won't say not to use it. There is an alternate libsass-python that you might want to look at if you're working with Python though.
Check out the django-sass-processor package. It's simple to configure and use. I've used it a few times and have had good experiences with it. The package abstracts away Gulp, so you don't have to worry about it and streamlines the whole process.
Here's a tutorial on how to integrate django-sass-processor into a Django project.

Difference between compiling Angular 2 typescript on server or give TS to transpiler

i just want to start with angular 2 right way. Im using django and django-pipeline. I tried pipeline typescript module, which compiling all .ts files in .js files. But i cannot run it, due errors and here is my question about that, so i still not get it working!
So for now i just followed official tutorial and got it running without compilation on server
So my question is, is it normal production setup to do like this, just leave all my problems to transpiler, or i need to fix my typescript compiller and files need to be JS.
What is the right way to build project with typescript and minification + maybe obfuscation.
Django-pipeline do all i dreamed about, but i cannot get it running with Angular, but typescript compiling ok.
I solved all my problems with angular2 webback

How can I deactivate Ember-cli JavaScript file concatenation in development?

By default, Ember-cli automatically concatenates JavaScript files into vendor.js and application.js (or <APP_NAME>.js). This makes tracebacks much less helpful. It appears that the default asset pipeline system, Broccoli, does not have a configuration flag for deactivating concatenation, but it also seems counterproductive to work around this by listing files manually.

Writing an ember-cli addon in Coffeescript

I'm trying to author an ember-cli addon, and I prefer to develop in Coffeescript. But it seems like the CLI build is hardcoded to look for just .js files. Is there any way to author an addon in Coffeescript and have the build take place with the consuming application's build (i.e. without me having to build the addon each time using a custom build process).
Yes, you can author in Coffeescript, but there was a bug in 0.0.46 where we would only preprocess *.js files in the addon tree. This is fixed on master, and should be included in 0.0.47 soonish...
So turns out this is a bug in the CLI, but it wasn't fixed in 0.0.47. See https://github.com/stefanpenner/ember-cli/issues/2354 for more context, it's currently an open issue & PR.

How can I use coffee script in a Django project?

I'm a new developer on Django and I want to use some CoffeeScript in my dummy project. However, documentation about this topic isn't good and I want to know from the experts which is the best option.
I was looking at possibilities like compressor but it is still confused. I'd really appreciate some pieces of advice.
Thanks in advance.
For automatic compilation, there's django-coffeescript. For a more complete toolchain (a bit like Rails Sprockets) there's Gears, a stand-alone project with plugins for Django, Flask or compilation on the command line.
When I've used CoffeeScript with Django however, I've mostly preferred to set up compilation as a part of a build process (great to have one in any case), there I mostly used custom Paver scripts together with directory watching tools (like watchdog/kicker) to compile .coffee files to Javascript and putting them in my static directory.
What exactly is your question? Django will let you use any JS libary you want. Just add it your HTML pages or templates as you would do without Django.
If it is about serving of staticfiles, check this: https://docs.djangoproject.com/en/1.4/ref/contrib/staticfiles/