@@ -45,12 +45,6 @@ COMPRESS_PRECOMPILERS = (
4545{% endcompress %}
4646```
4747
48- ``` scss
49- /* base/static/base/variables.scss */
50-
51- $title-size : 30px ;
52- ```
53-
5448``` scss
5549/* app/static/app/layout.scss */
5650
@@ -61,9 +55,15 @@ $title-size: 30px;
6155}
6256```
6357
58+ ``` scss
59+ /* base/static/base/variables.scss */
60+
61+ $title-size : 30px ;
62+ ```
63+
6464#### Requisites
6565
66- You need ` node-sass ` , ` postcss ` and ` autoprefixer ` to be installed. Quick install:
66+ You need ` node-sass ` , ` postcss-cli ` and ` autoprefixer ` to be installed. Quick install:
6767
6868``` sh
6969npm install -g node-sass postcss-cli autoprefixer
@@ -85,7 +85,6 @@ ES6 → (
8585
8686It also enables Django static imports in ES6, see the example below.
8787
88-
8988#### Usage
9089
9190``` py
@@ -106,6 +105,15 @@ COMPRESS_PRECOMPILERS = (
106105{% endcompress %}
107106```
108107
108+ ``` js
109+ // app/static/app/scripts.js
110+
111+ import Framework from ' base/framework' ;
112+
113+ new Framework ;
114+ new Framework (' 1.0.1' );
115+ ```
116+
109117``` js
110118// base/static/base/framework.js
111119
@@ -118,19 +126,61 @@ export default class {
118126}
119127```
120128
121- ``` js
122- // app/static/app/scripts.js
129+ #### Requisites
123130
124- import Framework from ' base/framework ' ;
131+ You need ` browserify ` , ` babelify ` and ` babel-preset-es2015 ` to be installed. Quick install:
125132
126- new Framework ;
127- new Framework ( ' 1.0.1 ' );
133+ ``` sh
134+ npm install -g browserify babelify babel-preset-es2015
128135```
129136
130- #### Requisites
137+ ## Django settings
131138
132- You need ` browserify ` , ` babelify ` and ` babel-preset-es2015 ` to be installed. Quick install:
139+ ### COMPRESS_NODE_MODULES
140+
141+ Path to ` node_modules ` where ` browserify ` , ` babelify ` , ` autoprefixer ` , etc, are installed.
142+
143+ Default: ` /usr/lib/node_modules `
144+
145+ ### COMPRESS_SCSS_COMPILER_CMD
146+
147+ Command that will be executed to transform SCSS into CSS code.
148+
149+ Default:
133150
134151``` sh
135- npm install -g browserify babelify babel-preset-es2015
152+ node-sass --output-style expanded {paths} " {infile}" " {outfile}" &&
153+ postcss --use " {node_modules}/autoprefixer" --autoprefixer.browsers " {autoprefixer_browsers}" -r " {outfile}" '
154+ ```
155+
156+ Placeholders:
157+ - `{infile}` - input file path
158+ - `{outfile}` - output file path
159+ - `{paths}` - specially for `node-sass`, include all Django app static folders:
160+ `--include-path=/path/to/app-1/static/ --include-path=/path/to/app-2/static/ ...`
161+ - `{node_modules}` - see `COMPRESS_NODE_MODULES` setting
162+ - `{autoprefixer_browsers}` - see `COMPRESS_AUTOPREFIXER_BROWSERS` setting
163+
164+ ### COMPRESS_AUTOPREFIXER_BROWSERS
165+
166+ Browser versions config for Autoprefixer.
167+
168+ Default: `ie >= 9, > 5%`
169+
170+ ### COMPRESS_ES6_COMPILER_CMD
171+
172+ Command that will be executed to transform ES6 into ES5 code.
173+
174+ Default:
175+
176+ ```sh
177+ export NODE_PATH="{paths}" && browserify "{infile}" -o "{outfile}" --no-bundle-external --node
178+ -t [ "{node_modules}/babelify" --presets="{node_modules}/babel-preset-es2015" ]
136179```
180+
181+ Placeholders:
182+ - `{infile}` - input file path
183+ - `{outfile}` - output file path
184+ - `{paths}` - specially for `browserify`, include all Django app static folders:
185+ `/path/to/app-1/static/:/path/to/app-2/static/:...` (like `PATH` variable)
186+ - `{node_modules}` - see `COMPRESS_NODE_MODULES` setting
0 commit comments