From 3d34ff2eda73966d49dad2d781428260531f0755 Mon Sep 17 00:00:00 2001 From: Alex Coles Date: Thu, 20 Nov 2014 15:20:39 +0100 Subject: [PATCH] Create Webpack entry points for each plugin User Story # #5697 Signed-off-by: Alex Coles --- .gitignore | 2 +- app/assets/javascripts/application.js.erb | 3 ++- config/rails-plugins.conf.js | 1 + webpack.config.js | 14 +++++++++++--- 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index c882a30968..72e6c49ddc 100644 --- a/.gitignore +++ b/.gitignore @@ -45,7 +45,7 @@ /backup /.project /.loadpath -/app/assets/javascripts/openproject-app.bundle.js* +/app/assets/javascripts/bundles/*.js* /config/additional_environment.rb /config/configuration.yml /config/database.yml diff --git a/app/assets/javascripts/application.js.erb b/app/assets/javascripts/application.js.erb index 9bcc17470a..fdd8086a03 100644 --- a/app/assets/javascripts/application.js.erb +++ b/app/assets/javascripts/application.js.erb @@ -54,7 +54,8 @@ //= require versions //= require_tree ./specific -//= require ./openproject-app.bundle +//= require ./bundles/openproject-app +//= require_tree ./bundles //source: http://stackoverflow.com/questions/8120065/jquery-and-prototype-dont-work-together-with-array-prototype-reverse if (typeof []._reverse == 'undefined') { diff --git a/config/rails-plugins.conf.js b/config/rails-plugins.conf.js index 5632788a4c..538d55471d 100644 --- a/config/rails-plugins.conf.js +++ b/config/rails-plugins.conf.js @@ -59,6 +59,7 @@ var TranslationsPlugin = { } }; +exports.pluginNamesPaths = OpenProjectPlugins.pluginNamesPaths(); exports.pluginDirectories = OpenProjectPlugins.pluginDirectories(); exports.translationsPluginLocales = TranslationsPlugin.findLocaleFiles(); exports.translationsPluginPath = TranslationsPlugin.findPluginPath(); diff --git a/webpack.config.js b/webpack.config.js index e810be13c2..b3517cf9fe 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -1,15 +1,23 @@ var webpack = require('webpack'), path = require('path'), + _ = require('lodash'), pathConfig = require('./config/rails-plugins.conf'); +var pluginEntries = _.reduce(pathConfig.pluginNamesPaths, function(entries, path, name) { + entries[name.replace(/^openproject\-/, '')] = name; + return entries; +}, {}); + module.exports = { context: __dirname + '/app/assets/javascripts/angular', - entry: './openproject-app.js', + entry: _.merge({ + app: './openproject-app.js' + }, pluginEntries), output: { - filename: 'openproject-app.bundle.js', - path: path.join(__dirname, 'app', 'assets', 'javascripts') + filename: 'openproject-[name].js', + path: path.join(__dirname, 'app', 'assets', 'javascripts', 'bundles') }, module: {