Prevent using the same object for both webpack configs

pull/4433/head
Alex Dik 9 years ago
parent 45a49fcc0a
commit 25b1e288a9
  1. 128
      frontend/webpack-main-config.js
  2. 21
      frontend/webpack-test-config.js
  3. 4
      frontend/webpack.config.js

@ -88,67 +88,69 @@ loaders.push({
}); });
var webpackConfig = { function getWebpackMainConfig() {
context: __dirname + '/app', return {
context: __dirname + '/app',
entry: _.merge({
'global': './global.js', entry: _.merge({
'core-app': './openproject-app.js' 'global': './global.js',
}, pluginEntries), 'core-app': './openproject-app.js'
}, pluginEntries),
output: {
filename: 'openproject-[name].js', output: {
path: path.join(__dirname, '..', 'app', 'assets', 'javascripts', 'bundles'), filename: 'openproject-[name].js',
publicPath: '/assets/bundles/' path: path.join(__dirname, '..', 'app', 'assets', 'javascripts', 'bundles'),
}, publicPath: '/assets/bundles/'
},
module: {
loaders: loaders, module: {
// Prevent 'This seems to be a pre-built javascript file.' error due to crossvent dist loaders: loaders,
noParse: /node_modules\/crossvent/, // Prevent 'This seems to be a pre-built javascript file.' error due to crossvent dist
}, noParse: /node_modules\/crossvent/
},
resolve: {
root: __dirname, resolve: {
root: __dirname,
extensions: ['', '.webpack.js', '.ts', '.js'],
extensions: ['', '.webpack.js', '.ts', '.js'],
modulesDirectories: [
'node_modules', modulesDirectories: [
'bower_components', 'node_modules',
'vendor' 'bower_components',
].concat(pathConfig.pluginDirectories), 'vendor'
].concat(pathConfig.pluginDirectories),
fallback: [path.join(__dirname, 'bower_components')],
fallback: [path.join(__dirname, 'bower_components')],
alias: _.merge({
'locales': './../../config/locales', alias: _.merge({
'locales': './../../config/locales',
'angular-ui-date': 'angular-ui-date/src/date',
'angular-truncate': 'angular-truncate/src/truncate', 'angular-ui-date': 'angular-ui-date/src/date',
'angular-context-menu': 'angular-context-menu/dist/angular-context-menu.js', 'angular-truncate': 'angular-truncate/src/truncate',
'mousetrap': 'mousetrap/mousetrap.js', 'angular-context-menu': 'angular-context-menu/dist/angular-context-menu.js',
'hyperagent': 'hyperagent/dist/hyperagent', 'mousetrap': 'mousetrap/mousetrap.js',
'ngFileUpload': 'ng-file-upload/ng-file-upload' 'hyperagent': 'hyperagent/dist/hyperagent',
}, pluginAliases) 'ngFileUpload': 'ng-file-upload/ng-file-upload'
}, }, pluginAliases)
},
resolveLoader: {
root: __dirname + '/node_modules' 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: [ module.exports = getWebpackMainConfig;
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;

@ -26,12 +26,19 @@
// See doc/COPYRIGHT.rdoc for more details. // See doc/COPYRIGHT.rdoc for more details.
// ++ // ++
var webpackConfig = require('./webpack-main-config'); var getWebpackMainConfig = require('./webpack-main-config');
webpackConfig.entry = './openproject-tests.js'; function getWebpackTestConfig() {
webpackConfig.output = { var webpackConfig = getWebpackMainConfig();
path: __dirname + '/tests',
filename: 'openproject-test-bundle.js'
};
module.exports = webpackConfig; webpackConfig.entry = './openproject-tests.js';
webpackConfig.output = {
path: __dirname + '/tests',
filename: 'openproject-test-bundle.js'
};
return webpackConfig;
}
module.exports = getWebpackTestConfig;

@ -27,6 +27,6 @@
// ++ // ++
module.exports = [ module.exports = [
require('./webpack-main-config'), require('./webpack-main-config')(),
require('./webpack-test-config') require('./webpack-test-config')()
]; ];

Loading…
Cancel
Save