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) { ...@@ -189,7 +189,11 @@ function normalizePathsForCoverage(files, normalizeFunc, preprocessors) {
files.forEach(function(file) { files.forEach(function(file) {
if (!file.ignoreCoverage) { if (!file.ignoreCoverage) {
normalizedFile = normalizeFn(appRoot, file.pattern); 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) { ...@@ -346,7 +350,13 @@ function getBaseConfig(config, useRequireJs) {
captureConsole: false captureConsole: false
}, },
webpack: webpackConfig webpack: webpackConfig,
webpackMiddleware: {
watchOptions: {
poll: true
}
}
}; };
} }
......
...@@ -18,8 +18,7 @@ ...@@ -18,8 +18,7 @@
* done. * done.
*/ */
modules: getModulesList([ modules: getModulesList([
'course_bookmarks/js/course_bookmarks_factory', 'course_bookmarks/js/course_bookmarks_factory',,
'course_experience/js/course_outline_factory',
'discussion/js/discussion_board_factory', 'discussion/js/discussion_board_factory',
'discussion/js/discussion_profile_page_factory', 'discussion/js/discussion_profile_page_factory',
'js/api_admin/catalog_preview_factory', 'js/api_admin/catalog_preview_factory',
......
...@@ -22,7 +22,7 @@ export class CourseOutline { // eslint-disable-line import/prefer-default-expor ...@@ -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) => { .forEach(link => link.addEventListener('click', (event) => {
Logger.log( Logger.log(
'edx.ui.lms.link_clicked', 'edx.ui.lms.link_clicked',
......
...@@ -19,6 +19,7 @@ from watchdog.events import PatternMatchingEventHandler ...@@ -19,6 +19,7 @@ from watchdog.events import PatternMatchingEventHandler
from .utils.envs import Env from .utils.envs import Env
from .utils.cmd import cmd, django_cmd from .utils.cmd import cmd, django_cmd
from .utils.timer import timed from .utils.timer import timed
from .utils.process import run_background_process
from openedx.core.djangoapps.theming.paver_helpers import get_theme_paths from openedx.core.djangoapps.theming.paver_helpers import get_theme_paths
...@@ -703,6 +704,16 @@ def execute_compile_sass(args): ...@@ -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): def get_parsed_option(command_opts, opt_key, default=None):
""" """
Extract user command option and parse it. Extract user command option and parse it.
...@@ -769,6 +780,11 @@ def watch_assets(options): ...@@ -769,6 +780,11 @@ def watch_assets(options):
print("Starting asset watcher...") print("Starting asset watcher...")
observer.start() 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): if not getattr(options, 'background', False):
# when running as a separate process, the main thread needs to loop # when running as a separate process, the main thread needs to loop
# in order to allow for shutdown by contrl-c # in order to allow for shutdown by contrl-c
...@@ -829,6 +845,7 @@ def update_assets(args): ...@@ -829,6 +845,7 @@ def update_assets(args):
process_xmodule_assets() process_xmodule_assets()
process_npm_assets() process_npm_assets()
compile_coffeescript() compile_coffeescript()
execute_webpack()
# Compile sass for themes and system # Compile sass for themes and system
execute_compile_sass(args) execute_compile_sass(args)
......
...@@ -40,6 +40,9 @@ EXPECTED_RUN_SERVER_COMMAND = ( ...@@ -40,6 +40,9 @@ EXPECTED_RUN_SERVER_COMMAND = (
EXPECTED_INDEX_COURSE_COMMAND = ( EXPECTED_INDEX_COURSE_COMMAND = (
u"python manage.py {system} --settings={settings} reindex_course --setup" u"python manage.py {system} --settings={settings} reindex_course --setup"
) )
EXPECTED_WEBPACK_COMMAND = (
u"$(npm bin)/webpack"
)
@ddt.ddt @ddt.ddt
...@@ -233,6 +236,7 @@ class TestPaverServerTasks(PaverTestCase): ...@@ -233,6 +236,7 @@ class TestPaverServerTasks(PaverTestCase):
expected_messages.append(u"xmodule_assets common/static/xmodule") expected_messages.append(u"xmodule_assets common/static/xmodule")
expected_messages.append(u"install npm_assets") expected_messages.append(u"install npm_assets")
expected_messages.append(EXPECTED_COFFEE_COMMAND.format(platform_root=self.platform_root)) 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)) expected_messages.extend(self.expected_sass_commands(system=system, asset_settings=expected_asset_settings))
if expected_collect_static: if expected_collect_static:
expected_messages.append(EXPECTED_COLLECT_STATIC_COMMAND.format( expected_messages.append(EXPECTED_COLLECT_STATIC_COMMAND.format(
...@@ -270,6 +274,7 @@ class TestPaverServerTasks(PaverTestCase): ...@@ -270,6 +274,7 @@ class TestPaverServerTasks(PaverTestCase):
expected_messages.append(u"xmodule_assets common/static/xmodule") expected_messages.append(u"xmodule_assets common/static/xmodule")
expected_messages.append(u"install npm_assets") expected_messages.append(u"install npm_assets")
expected_messages.append(EXPECTED_COFFEE_COMMAND.format(platform_root=self.platform_root)) 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)) expected_messages.extend(self.expected_sass_commands(asset_settings=expected_asset_settings))
if expected_collect_static: if expected_collect_static:
expected_messages.append(EXPECTED_COLLECT_STATIC_COMMAND.format( expected_messages.append(EXPECTED_COLLECT_STATIC_COMMAND.format(
......
...@@ -45,6 +45,10 @@ var wpconfig = { ...@@ -45,6 +45,10 @@ var wpconfig = {
resolve: { resolve: {
extensions: ['.js', '.json'] 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