From 25b1e288a909c75d84d0130f8f2452d883fa2627 Mon Sep 17 00:00:00 2001 From: Alex Dik Date: Thu, 19 May 2016 20:24:09 +0200 Subject: [PATCH] Prevent using the same object for both webpack configs --- frontend/webpack-main-config.js | 128 ++++++++++++++++---------------- frontend/webpack-test-config.js | 21 ++++-- frontend/webpack.config.js | 4 +- 3 files changed, 81 insertions(+), 72 deletions(-) diff --git a/frontend/webpack-main-config.js b/frontend/webpack-main-config.js index bc6be72f13..f02c5ef874 100644 --- a/frontend/webpack-main-config.js +++ b/frontend/webpack-main-config.js @@ -88,67 +88,69 @@ loaders.push({ }); -var webpackConfig = { - context: __dirname + '/app', - - entry: _.merge({ - 'global': './global.js', - 'core-app': './openproject-app.js' - }, pluginEntries), - - output: { - filename: 'openproject-[name].js', - path: path.join(__dirname, '..', 'app', 'assets', 'javascripts', 'bundles'), - publicPath: '/assets/bundles/' - }, - - module: { - loaders: loaders, - // Prevent 'This seems to be a pre-built javascript file.' error due to crossvent dist - noParse: /node_modules\/crossvent/, - }, - - resolve: { - root: __dirname, - - extensions: ['', '.webpack.js', '.ts', '.js'], - - modulesDirectories: [ - 'node_modules', - 'bower_components', - 'vendor' - ].concat(pathConfig.pluginDirectories), - - fallback: [path.join(__dirname, 'bower_components')], - - alias: _.merge({ - 'locales': './../../config/locales', - - 'angular-ui-date': 'angular-ui-date/src/date', - 'angular-truncate': 'angular-truncate/src/truncate', - 'angular-context-menu': 'angular-context-menu/dist/angular-context-menu.js', - 'mousetrap': 'mousetrap/mousetrap.js', - 'hyperagent': 'hyperagent/dist/hyperagent', - 'ngFileUpload': 'ng-file-upload/ng-file-upload' - }, pluginAliases) - }, - - resolveLoader: { - root: __dirname + '/node_modules' - }, +function getWebpackMainConfig() { + return { + context: __dirname + '/app', + + entry: _.merge({ + 'global': './global.js', + 'core-app': './openproject-app.js' + }, pluginEntries), + + output: { + filename: 'openproject-[name].js', + path: path.join(__dirname, '..', 'app', 'assets', 'javascripts', 'bundles'), + publicPath: '/assets/bundles/' + }, + + module: { + loaders: loaders, + // Prevent 'This seems to be a pre-built javascript file.' error due to crossvent dist + noParse: /node_modules\/crossvent/ + }, + + resolve: { + root: __dirname, + + extensions: ['', '.webpack.js', '.ts', '.js'], + + modulesDirectories: [ + 'node_modules', + 'bower_components', + 'vendor' + ].concat(pathConfig.pluginDirectories), + + fallback: [path.join(__dirname, 'bower_components')], + + alias: _.merge({ + 'locales': './../../config/locales', + + 'angular-ui-date': 'angular-ui-date/src/date', + 'angular-truncate': 'angular-truncate/src/truncate', + 'angular-context-menu': 'angular-context-menu/dist/angular-context-menu.js', + 'mousetrap': 'mousetrap/mousetrap.js', + 'hyperagent': 'hyperagent/dist/hyperagent', + 'ngFileUpload': 'ng-file-upload/ng-file-upload' + }, pluginAliases) + }, + + resolveLoader: { + root: __dirname + '/node_modules' + }, + + plugins: [ + new ExtractTextPlugin('openproject-[name].css'), + new webpack.ProvidePlugin({ + '_': 'lodash', + 'URI': 'URIjs', + 'URITemplate': 'URIjs/src/URITemplate' + }), + new webpack.ResolverPlugin([ + new webpack.ResolverPlugin.DirectoryDescriptionFilePlugin( + 'bower.json', ['main']) + ]) + ] + }; +} - plugins: [ - new ExtractTextPlugin('openproject-[name].css'), - new webpack.ProvidePlugin({ - '_': 'lodash', - 'URI': 'URIjs', - 'URITemplate': 'URIjs/src/URITemplate' - }), - new webpack.ResolverPlugin([ - new webpack.ResolverPlugin.DirectoryDescriptionFilePlugin( - 'bower.json', ['main']) - ]) - ] -}; - -module.exports = webpackConfig; +module.exports = getWebpackMainConfig; diff --git a/frontend/webpack-test-config.js b/frontend/webpack-test-config.js index f9191c65af..8c17d734c0 100644 --- a/frontend/webpack-test-config.js +++ b/frontend/webpack-test-config.js @@ -26,12 +26,19 @@ // See doc/COPYRIGHT.rdoc for more details. // ++ -var webpackConfig = require('./webpack-main-config'); +var getWebpackMainConfig = require('./webpack-main-config'); -webpackConfig.entry = './openproject-tests.js'; -webpackConfig.output = { - path: __dirname + '/tests', - filename: 'openproject-test-bundle.js' -}; +function getWebpackTestConfig() { + var webpackConfig = getWebpackMainConfig(); -module.exports = webpackConfig; + webpackConfig.entry = './openproject-tests.js'; + webpackConfig.output = { + path: __dirname + '/tests', + filename: 'openproject-test-bundle.js' + }; + + return webpackConfig; +} + + +module.exports = getWebpackTestConfig; diff --git a/frontend/webpack.config.js b/frontend/webpack.config.js index 19769b5038..51ae92b13f 100644 --- a/frontend/webpack.config.js +++ b/frontend/webpack.config.js @@ -27,6 +27,6 @@ // ++ module.exports = [ - require('./webpack-main-config'), - require('./webpack-test-config') + require('./webpack-main-config')(), + require('./webpack-test-config')() ];