summaryrefslogtreecommitdiff
path: root/config/webpack.config.js
diff options
context:
space:
mode:
authorClement Ho <clemmakesapps@gmail.com>2018-02-27 20:08:20 +0000
committerClement Ho <clemmakesapps@gmail.com>2018-02-27 20:08:20 +0000
commitf20ee984d2322eef9908134d041e446e259b585c (patch)
treed0eb70b62d9f702cd7132a279d5b56bd36400a69 /config/webpack.config.js
parent124ce3b6e31f2da678629eb9bf68c2f92aa1bd55 (diff)
parentd4867c518f2d72125c619c191fa9577dabb1ae9a (diff)
downloadgitlab-ce-f20ee984d2322eef9908134d041e446e259b585c.tar.gz
Merge branch 'master' into 'pipelines_show_refactor'
# Conflicts: # config/webpack.config.js
Diffstat (limited to 'config/webpack.config.js')
-rw-r--r--config/webpack.config.js92
1 files changed, 52 insertions, 40 deletions
diff --git a/config/webpack.config.js b/config/webpack.config.js
index 1cdd1d83baf..9367dfcc5ec 100644
--- a/config/webpack.config.js
+++ b/config/webpack.config.js
@@ -21,63 +21,49 @@ var DEV_SERVER_LIVERELOAD = process.env.DEV_SERVER_LIVERELOAD !== 'false';
var WEBPACK_REPORT = process.env.WEBPACK_REPORT;
var NO_COMPRESSION = process.env.NO_COMPRESSION;
-// generate automatic entry points
-var autoEntries = {};
-var pageEntries = glob.sync('pages/**/index.js', { cwd: path.join(ROOT_PATH, 'app/assets/javascripts') });
-
-// filter out entries currently imported dynamically in dispatcher.js
-var dispatcher = fs.readFileSync(path.join(ROOT_PATH, 'app/assets/javascripts/dispatcher.js')).toString();
-var dispatcherChunks = dispatcher.match(/(?!import\(')\.\/pages\/[^']+/g);
-
-function generateAutoEntries(path, prefix = '.') {
- const chunkPath = path.replace(/\/index\.js$/, '');
- if (!dispatcherChunks.includes(`${prefix}/${chunkPath}`)) {
+var autoEntriesCount = 0;
+var watchAutoEntries = [];
+
+function generateEntries() {
+ // generate automatic entry points
+ var autoEntries = {};
+ var pageEntries = glob.sync('pages/**/index.js', { cwd: path.join(ROOT_PATH, 'app/assets/javascripts') });
+ watchAutoEntries = [
+ path.join(ROOT_PATH, 'app/assets/javascripts/pages/'),
+ ];
+
+ function generateAutoEntries(path, prefix = '.') {
+ const chunkPath = path.replace(/\/index\.js$/, '');
const chunkName = chunkPath.replace(/\//g, '.');
autoEntries[chunkName] = `${prefix}/${path}`;
}
-}
-pageEntries.forEach(( path ) => generateAutoEntries(path));
+ pageEntries.forEach(( path ) => generateAutoEntries(path));
-// report our auto-generated bundle count
-var autoEntriesCount = Object.keys(autoEntries).length;
-console.log(`${autoEntriesCount} entries from '/pages' automatically added to webpack output.`);
+ autoEntriesCount = Object.keys(autoEntries).length;
-var config = {
- // because sqljs requires fs.
- node: {
- fs: "empty"
- },
- context: path.join(ROOT_PATH, 'app/assets/javascripts'),
- entry: {
+ const manualEntries = {
balsamiq_viewer: './blob/balsamiq_viewer.js',
- blob: './blob_edit/blob_bundle.js',
- boards: './boards/boards_bundle.js',
+ common: './commons/index.js',
+ common_vue: './vue_shared/vue_resource_interceptor.js',
cycle_analytics: './cycle_analytics/cycle_analytics_bundle.js',
- commit_pipelines: './commit/pipelines/pipelines_bundle.js',
- diff_notes: './diff_notes/diff_notes_bundle.js',
environments: './environments/environments_bundle.js',
- environments_folder: './environments/folder/environments_folder_bundle.js',
filtered_search: './filtered_search/filtered_search_bundle.js',
help: './help/help.js',
merge_conflicts: './merge_conflicts/merge_conflicts_bundle.js',
monitoring: './monitoring/monitoring_bundle.js',
- network: './network/network_bundle.js',
notebook_viewer: './blob/notebook_viewer.js',
pdf_viewer: './blob/pdf_viewer.js',
- pipelines: './pipelines/pipelines_bundle.js',
profile: './profile/profile_bundle.js',
project_import_gl: './projects/project_import_gitlab_project.js',
protected_branches: './protected_branches',
protected_tags: './protected_tags',
registry_list: './registry/index.js',
- sidebar: './sidebar/sidebar_bundle.js',
snippet: './snippet/snippet_bundle.js',
sketch_viewer: './blob/sketch_viewer.js',
stl_viewer: './blob/stl_viewer.js',
terminal: './terminal/terminal_bundle.js',
ui_development_kit: './ui_development_kit.js',
- vue_merge_request_widget: './vue_merge_request_widget/index.js',
two_factor_auth: './two_factor_auth.js',
@@ -90,7 +76,15 @@ var config = {
test: './test.js',
u2f: ['vendor/u2f'],
webpack_runtime: './webpack.js',
- },
+ };
+
+ return Object.assign(manualEntries, autoEntries);
+}
+
+var config = {
+ context: path.join(ROOT_PATH, 'app/assets/javascripts'),
+
+ entry: generateEntries,
output: {
path: path.join(ROOT_PATH, 'public/assets/webpack'),
@@ -243,12 +237,9 @@ var config = {
name: 'common_vue',
chunks: [
'boards',
- 'commit_pipelines',
'cycle_analytics',
'deploy_keys',
- 'diff_notes',
'environments',
- 'environments_folder',
'filtered_search',
'groups',
'merge_conflicts',
@@ -308,11 +299,15 @@ var config = {
'images': path.join(ROOT_PATH, 'app/assets/images'),
'vendor': path.join(ROOT_PATH, 'vendor/assets/javascripts'),
'vue$': 'vue/dist/vue.esm.js',
+ 'spec': path.join(ROOT_PATH, 'spec/javascripts'),
}
- }
-}
+ },
-config.entry = Object.assign({}, autoEntries, config.entry);
+ // sqljs requires fs
+ node: {
+ fs: 'empty',
+ },
+};
if (IS_PRODUCTION) {
config.devtool = 'source-map';
@@ -349,7 +344,24 @@ if (IS_DEV_SERVER) {
};
config.plugins.push(
// watch node_modules for changes if we encounter a missing module compile error
- new WatchMissingNodeModulesPlugin(path.join(ROOT_PATH, 'node_modules'))
+ new WatchMissingNodeModulesPlugin(path.join(ROOT_PATH, 'node_modules')),
+
+ // watch for changes to our automatic entry point modules
+ {
+ apply(compiler) {
+ compiler.plugin('emit', (compilation, callback) => {
+ compilation.contextDependencies = [
+ ...compilation.contextDependencies,
+ ...watchAutoEntries,
+ ];
+
+ // report our auto-generated bundle count
+ console.log(`${autoEntriesCount} entries from '/pages' automatically added to webpack output.`);
+
+ callback();
+ })
+ },
+ },
);
if (DEV_SERVER_LIVERELOAD) {
config.plugins.push(new webpack.HotModuleReplacementPlugin());