Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add and document "shallow recompiles" option #25

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 16 additions & 12 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,20 @@ And add it as a compiler to pipeline in your django `settings.py`::
# ...
)

**Important:** give your entry-point file a `.browserify.js` extension::

PIPELINE = {
# ...
'javascript':{
'browserify': {
'source_filenames' : (
'js/entry-point.browserify.js',
),
'output_filename': 'js/entry-point.js',
},
}
}

To add source maps during development (or any other browserify args)::

if DEBUG:
Expand Down Expand Up @@ -45,20 +59,10 @@ To use a local install of the browserify command line utility (or if it is not i
# ...or perhaps something like this:
PIPELINE['BROWSERIFY_BINARY'] = os.path.join(REPO_ROOT, "node_modules/.bin", "browserify"),

By default a full check of your entry point **and its dependencies** is performed to see if the output is stale. This produces the most correct behavior, but with a large JavaScript codebase can cause very slow page refreshes — even when nothing has changed! To use only the main entry point's modification time when determining if recompilation is needed, set:

**Important:** give your entry-point file a `.browserify.js` extension::
PIPELINE['BROWSERIFY_SHALLOW_RECOMPILES'] = True

PIPELINE = {
# ...
'javascript':{
'browserify': {
'source_filenames' : (
'js/entry-point.browserify.js',
),
'output_filename': 'js/entry-point.js',
},
}
}

To suggest a feature or report a bug:
https://github.com/j0hnsmith/django-pipeline-browserify/issues
4 changes: 4 additions & 0 deletions pipeline_browserify/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ def is_outdated(self, infile, outfile):
if super(BrowserifyCompiler, self).is_outdated(infile, outfile):
return True

pipeline_settings = getattr(settings, 'PIPELINE', {})
if pipeline_settings.get('BROWSERIFY_SHALLOW_RECOMPILES', False):
return False

# Otherwise we need to see what dependencies there are now, and if they're modified.
tool, args, env = self._get_cmd_parts()
cmd = [tool] + args + ['--list', infile]
Expand Down