2021-03-21 13:38:28 +00:00
const webpack = require ( 'webpack' ) ;
const HtmlWebpackPlugin = require ( 'html-webpack-plugin' ) ;
2021-03-21 13:51:53 +00:00
const NodePolyfillPlugin = require ( 'node-polyfill-webpack-plugin' ) ;
2021-03-21 13:38:28 +00:00
const MiniCssExtractPlugin = require ( 'mini-css-extract-plugin' ) ;
const path = require ( 'path' ) ;
module . exports = env => ( {
2021-03-21 13:51:53 +00:00
mode : 'development' ,
entry : path . resolve ( _ _dirname , './webpack-tests.js' ) ,
resolve : {
alias : {
'fsProvider' : path . resolve ( _ _dirname , '../shims/providers/default' ) ,
2021-03-21 13:38:28 +00:00
} ,
2021-03-21 13:51:53 +00:00
} ,
output : {
path : path . resolve ( _ _dirname , './dist-webpack' ) ,
filename : 'index.js' ,
} ,
plugins : [
new webpack . ContextReplacementPlugin (
// Mocha safely uses require in such a way that webpack cannot statically extract dependancies.
// If the ignoreRequestDependancyExpressionWarnings env is set, we will aggregate these warnings
// into one summary warning to minimise spamming the console.
/\/node_modules\/mocha\/lib/ ,
( data ) => {
if ( env . ignoreRequestDependancyExpressionWarnings ) {
let requestDependencyExpressionsIgnored = 0 ;
data . dependencies . forEach ( ( dependancy ) => {
if ( dependancy . critical === 'the request of a dependency is an expression' ) {
dependancy . critical = undefined ;
requestDependencyExpressionsIgnored += 1 ;
}
} ) ;
console . log ( ` WARNING: Ignoring ${ requestDependencyExpressionsIgnored } "request of a dependency is an expression" warnings from "node_modules/mocha/lib". ` ) ;
}
return data ;
} ,
) ,
new NodePolyfillPlugin ( ) ,
new MiniCssExtractPlugin ( ) ,
new HtmlWebpackPlugin ( {
title : 'Filer Tests - Webpack Build' ,
template : './tests/webpack.index.html' ,
} ) ,
] ,
module : {
rules : [
{
test : /\.css$/i ,
use : [ MiniCssExtractPlugin . loader , 'css-loader' ] ,
} ,
2021-03-21 13:38:28 +00:00
] ,
2021-03-21 13:51:53 +00:00
} ,
optimization : {
minimize : false ,
} ,
devtool : 'inline-source-map' ,
devServer : {
contentBase : path . resolve ( _ _dirname , './dist-webpack' ) ,
}
2021-03-21 13:38:28 +00:00
} ) ;