-
Notifications
You must be signed in to change notification settings - Fork 220
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using CommonsChunkPlugin #22
Comments
nope. We are pretty limited because of the way karma works. This plugin must deliver exactly one output file per input file. |
I was just about to ask for this as well. There's no way to serve all compiled files to served from webpack to karma? |
Any chance integration could be achieve by a Karma |
I'm hitting this issue as well. I'd like to use my separate bundles for running tests with. I created a SO issue here http://stackoverflow.com/questions/30553414/structuring-webpack-config-for-use-with-karma-testing |
I think the best approach is having a separate webpack.karma.config as I mention in #91 |
Agreed with @goldhand, we should document what plugin are _not_ supported with karma-webpack |
@goldhand - People are trying to use CommonsChunk to solve performance issues on test runs and after throwing a few hundred tests at karma-wepback to test an old issue, I understand their gripes. If you think about it, chunking common libs on test runs makes sense from an efficiency standpoint. It's down the road a bit as we have plenty of |
I am using Karma-Webpack for my project and this is how i implement CommonChunkPlugins in Karma-Wepack.
module.exports = function (config) {
config.set({
basePath: '',
frameworks: ['jasmine', 'requirejs'],
preprocessors: {
'tests/common.js': ['webpack', 'sourcemap'],
'tests/specs/**/*.spec.js': ['webpack', 'sourcemap']
},
webpack: {
context: path.resolve(__dirname, 'tests'),
entry: {
common: './common.js'
},
devtool: 'inline-source-map',
output: {
path: path.resolve(__dirname, 'tests'),
filename: '[name].bundle.js',
chunkFilename: '[name].js',
jsonpFunction: '__TestAmd'
},
resolve: {
alias: {
'base': path.resolve(__dirname, 'src')
}
},
module: {
rules: [
{
test: /\.js$/,
exclude: /(node_modules|bower_components)/,
use: [
{
loader: 'babel-loader',
options: {
presets: [
'es2015'
],
plugins: [
'syntax-dynamic-import'
]
}
}
]
}
]
},
plugins: [
new CommonsChunkPlugin({
name: 'tests/common.js',
minChunks: function ({ resource }) {
return resource &&
resource.indexOf('node_modules') >= 0 &&
resource.match(/\.js$/);
}
})
]
},
// list of files / patterns to load in the browser
files: [
'tests/test-main.js',
'tests/common.js',
{pattern: 'tests/specs/**/*.js', included: false},
],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['Chrome'],
captureTimeout: 60000,
browserNoActivityTimeout: 100000,
singleRun: false,
concurrency: Infinity
});
}; Hope it helps |
@jack-vo It is pretty cool! |
@jack-vo have you had any luck making this work with Webpack 4? It works for me, but I'm getting a "Conflict: Multiple assets emit to the same filename test/common.bundle.js" warning and was wondering if you found a workaround yet. Thanks! |
Never mind, for anyone who was unable to get @jack-vo 's workaround, make sure you output the stats of webpack and ensure that there are only 2 bundles being emitted. If there are more than two, it's possible the webpack runtime will be output to another bundle (thats just how it works, if it's not specified in entries) |
|
Is there a way to use CommonsChunkPlugin with karma-webpack to exclude vendor libs from test bundles?
The text was updated successfully, but these errors were encountered: