@@ -71,6 +71,12 @@ $title-size: 30px;
7171
7272You need ` node-sass ` , ` postcss-cli ` and ` autoprefixer ` to be installed. Quick install:
7373
74+ ``` sh
75+ npm install node-sass postcss-cli autoprefixer
76+ ```
77+
78+ Or you can install them globally (you need to set ` COMPRESS_LOCAL_NPM_INSTALL = False ` ):
79+
7480``` sh
7581npm install -g node-sass postcss-cli autoprefixer
7682```
@@ -136,55 +142,89 @@ export default class {
136142
137143You need ` browserify ` , ` babelify ` and ` babel-preset-es2015 ` to be installed. Quick install:
138144
145+ ``` sh
146+ npm install browserify babelify babel-preset-es2015
147+ ```
148+
149+ Or you can install them globally (you need to set ` COMPRESS_LOCAL_NPM_INSTALL = False ` ):
150+
139151``` sh
140152npm install -g browserify babelify babel-preset-es2015
141153```
142154
143155## Django settings
144156
157+ ### ` COMPRESS_LOCAL_NPM_INSTALL `
158+
159+ Whether you install required NPM packages _ locally_ .
160+
161+ Default: ` True ` .
162+
145163### ` COMPRESS_NODE_MODULES `
146164
147- Path to ` node_modules ` where ` browserify ` , ` babelify ` , ` autoprefixer ` , etc, are installed.
165+ Path to ` node_modules ` where ` babelify ` , ` autoprefixer ` , etc, libs are installed.
166+
167+ Default: ` ./node_modules ` if ` COMPRESS_LOCAL_NPM_INSTALL ` else ` /usr/lib/node_modules ` .
168+
169+ ### ` COMPRESS_NODE_SASS_BIN `
170+
171+ ` node-sass ` executable. It may be just the executable name (if it's on ` PATH ` ) or the executable path.
172+
173+ Default: ` ./node_modules/.bin/node-sass ` if ` COMPRESS_LOCAL_NPM_INSTALL ` else ` node-sass ` .
148174
149- Default: ` /usr/lib/node_modules `
175+ ### ` COMPRESS_POSTCSS_BIN `
176+
177+ ` postcss ` executable. It may be just the executable name (if it's on ` PATH ` ) or the executable path.
178+
179+ Default: ` ./node_modules/.bin/postcss ` if ` COMPRESS_LOCAL_NPM_INSTALL ` else ` postcss ` .
180+
181+ ### ` COMPRESS_AUTOPREFIXER_BROWSERS `
182+
183+ Browser versions config for Autoprefixer.
184+
185+ Default: ` ie >= 9, > 5% ` .
150186
151187### ` COMPRESS_SCSS_COMPILER_CMD `
152188
153189Command that will be executed to transform SCSS into CSS code.
154190
155191Default:
156192
157- ``` sh
158- node-sass --output-style expanded {paths} " {infile}" " {outfile}" &&
159- postcss --use " {node_modules}/autoprefixer" --autoprefixer.browsers " {autoprefixer_browsers}" -r " {outfile}"
193+ ``` py
194+ ' {node_sass_bin} --output-style expanded {paths} "{infile}" "{outfile}" && '
195+ ' {postcss_bin} --use "{node_modules}/autoprefixer" --autoprefixer.browsers "{autoprefixer_browsers}" -r "{outfile}"'
160196```
161197
162- Placeholders:
198+ Placeholders (i.e. they ** can be re-used** in custom ` COMPRESS_SCSS_COMPILER_CMD ` string):
199+ - ` {node_sass_bin} ` - value from ` COMPRESS_NODE_SASS_BIN `
200+ - ` {postcss_bin} ` - value from ` COMPRESS_POSTCSS_BIN `
163201- ` {infile} ` - input file path
164202- ` {outfile} ` - output file path
165203- ` {paths} ` - specially for ` node-sass ` , include all Django app static folders:
166204 ` --include-path=/path/to/app-1/static/ --include-path=/path/to/app-2/static/ ... `
167205- ` {node_modules} ` - see ` COMPRESS_NODE_MODULES ` setting
168- - ` {autoprefixer_browsers} ` - see ` COMPRESS_AUTOPREFIXER_BROWSERS ` setting
206+ - ` {autoprefixer_browsers} ` - value from ` COMPRESS_AUTOPREFIXER_BROWSERS `
169207
170- ### ` COMPRESS_AUTOPREFIXER_BROWSERS `
208+ ### ` COMPRESS_BROWSERIFY_BIN `
171209
172- Browser versions config for Autoprefixer .
210+ ` browserify ` executable. It may be just the executable name (if it's on ` PATH ` ) or the executable path .
173211
174- Default: ` ie >= 9, > 5% `
212+ Default: ` ./node_modules/.bin/browserify ` if ` COMPRESS_LOCAL_NPM_INSTALL ` else ` browserify ` .
175213
176214### ` COMPRESS_ES6_COMPILER_CMD `
177215
178216Command that will be executed to transform ES6 into ES5 code.
179217
180218Default:
181219
182- ``` sh
183- export NODE_PATH=" {paths}" && browserify " {infile}" -o " {outfile}" --no-bundle-external --node
184- -t [ " {node_modules}/babelify" --presets= " {node_modules}/babel-preset-es2015" ]
220+ ``` py
221+ ' export NODE_PATH="{paths}" && '
222+ ' {browserify_bin} "{infile}" -o "{outfile}" --no-bundle-external --node '
223+ ' -t [ "{node_modules}/babelify" --presets="{node_modules}/babel-preset-es2015" ]'
185224```
186225
187226Placeholders:
227+ - ` {browserify_bin} ` - value from ` COMPRESS_BROWSERIFY_BIN `
188228- ` {infile} ` - input file path
189229- ` {outfile} ` - output file path
190230- ` {paths} ` - specially for ` browserify ` , include all Django app static folders:
@@ -197,5 +237,6 @@ Placeholders:
197237git clone https://github.com/kottenator/django-compressor-toolkit.git
198238cd django-compressor-toolkit
199239pip install -e ' .[test]'
240+ npm install
200241py.test
201242```
0 commit comments