Commit 3b43fb38 by Brian Jacobel

Paver runs Webpack (incl watcher) in dev and test

parent ef4b5cb8
......@@ -189,7 +189,11 @@ function normalizePathsForCoverage(files, normalizeFunc, preprocessors) {
files.forEach(function(file) {
if (!file.ignoreCoverage) {
normalizedFile = normalizeFn(appRoot, file.pattern);
filesForCoverage[normalizedFile] = ['coverage'].concat(preprocessors[normalizedFile] || []);
if (preprocessors && preprocessors.hasOwnProperty(normalizedFile)) {
filesForCoverage[normalizedFile] = ['coverage'].concat(preprocessors[normalizedFile]);
} else {
filesForCoverage[normalizedFile] = ['coverage'];
}
}
});
......@@ -346,7 +350,13 @@ function getBaseConfig(config, useRequireJs) {
captureConsole: false
},
webpack: webpackConfig
webpack: webpackConfig,
webpackMiddleware: {
watchOptions: {
poll: true
}
}
};
}
......
......@@ -18,8 +18,7 @@
* done.
*/
modules: getModulesList([
'course_bookmarks/js/course_bookmarks_factory',
'course_experience/js/course_outline_factory',
'course_bookmarks/js/course_bookmarks_factory',,
'discussion/js/discussion_board_factory',
'discussion/js/discussion_profile_page_factory',
'js/api_admin/catalog_preview_factory',
......
......@@ -22,7 +22,7 @@ export class CourseOutline { // eslint-disable-line import/prefer-default-expor
}
}));
document.querySelectorAll('a:not([href^="#"])')
[...document.querySelectorAll('a:not([href^="#"])')]
.forEach(link => link.addEventListener('click', (event) => {
Logger.log(
'edx.ui.lms.link_clicked',
......
......@@ -19,6 +19,7 @@ from watchdog.events import PatternMatchingEventHandler
from .utils.envs import Env
from .utils.cmd import cmd, django_cmd
from .utils.timer import timed
from .utils.process import run_background_process
from openedx.core.djangoapps.theming.paver_helpers import get_theme_paths
......@@ -703,6 +704,16 @@ def execute_compile_sass(args):
)
@task
@no_help
def execute_webpack():
sh(cmd("$(npm bin)/webpack"))
def execute_webpack_watch():
run_background_process("$(npm bin)/webpack --watch --watch-poll=200")
def get_parsed_option(command_opts, opt_key, default=None):
"""
Extract user command option and parse it.
......@@ -769,6 +780,11 @@ def watch_assets(options):
print("Starting asset watcher...")
observer.start()
# We only want Webpack to re-run on changes to its own entry points, not all JS files, so we use its own watcher
# instead of subclassing from Watchdog like the other watchers do
execute_webpack_watch()
if not getattr(options, 'background', False):
# when running as a separate process, the main thread needs to loop
# in order to allow for shutdown by contrl-c
......@@ -829,6 +845,7 @@ def update_assets(args):
process_xmodule_assets()
process_npm_assets()
compile_coffeescript()
execute_webpack()
# Compile sass for themes and system
execute_compile_sass(args)
......
......@@ -40,6 +40,9 @@ EXPECTED_RUN_SERVER_COMMAND = (
EXPECTED_INDEX_COURSE_COMMAND = (
u"python manage.py {system} --settings={settings} reindex_course --setup"
)
EXPECTED_WEBPACK_COMMAND = (
u"$(npm bin)/webpack"
)
@ddt.ddt
......@@ -233,6 +236,7 @@ class TestPaverServerTasks(PaverTestCase):
expected_messages.append(u"xmodule_assets common/static/xmodule")
expected_messages.append(u"install npm_assets")
expected_messages.append(EXPECTED_COFFEE_COMMAND.format(platform_root=self.platform_root))
expected_messages.append(EXPECTED_WEBPACK_COMMAND)
expected_messages.extend(self.expected_sass_commands(system=system, asset_settings=expected_asset_settings))
if expected_collect_static:
expected_messages.append(EXPECTED_COLLECT_STATIC_COMMAND.format(
......@@ -270,6 +274,7 @@ class TestPaverServerTasks(PaverTestCase):
expected_messages.append(u"xmodule_assets common/static/xmodule")
expected_messages.append(u"install npm_assets")
expected_messages.append(EXPECTED_COFFEE_COMMAND.format(platform_root=self.platform_root))
expected_messages.append(EXPECTED_WEBPACK_COMMAND)
expected_messages.extend(self.expected_sass_commands(asset_settings=expected_asset_settings))
if expected_collect_static:
expected_messages.append(EXPECTED_COLLECT_STATIC_COMMAND.format(
......
......@@ -45,6 +45,10 @@ var wpconfig = {
resolve: {
extensions: ['.js', '.json']
},
watchOptions: {
poll: true
}
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment