You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

39 lines
878 B

import path from 'path'
import webpack from 'webpack'
import MemoryFS from 'memory-fs'
export function compileWithWebpack (file, extraConfig, cb) {
const config = Object.assign({
mode: 'development',
entry: path.resolve(__dirname, 'fixtures', file),
module: {
rules: [
{
test: /\.js$/,
loader: 'babel-loader'
},
{
test: /async-.*\.js$/,
loader: require.resolve('./async-loader')
},
{
test: /\.(png|woff2|css)$/,
loader: 'file-loader',
options: {
name: '[name].[ext]'
}
}
]
}
}, extraConfig)
const compiler = webpack(config)
const fs = new MemoryFS()
compiler.outputFileSystem = fs
compiler.run((err, stats) => {
expect(err).toBeFalsy()
expect(stats.errors).toBeFalsy()
cb(fs)
})
}