2019-05-10 04:51:56 +02:00
|
|
|
/**
|
|
|
|
* Webpack configuration for building unit tests
|
|
|
|
*/
|
2019-05-10 04:03:13 +02:00
|
|
|
var path = require('path');
|
|
|
|
var webpack = require('webpack');
|
|
|
|
|
2021-05-01 09:17:31 +02:00
|
|
|
module.exports = () => {
|
2019-05-10 04:03:13 +02:00
|
|
|
const statsConfig = {
|
|
|
|
builtAt: true,
|
|
|
|
children: false,
|
|
|
|
chunks: false,
|
|
|
|
chunkGroups: false,
|
|
|
|
chunkModules: false,
|
|
|
|
chunkOrigins: false,
|
|
|
|
colors: true,
|
|
|
|
entrypoints: true,
|
|
|
|
}
|
|
|
|
|
|
|
|
return {
|
|
|
|
plugins: [
|
|
|
|
new webpack.DefinePlugin({
|
2021-04-30 05:52:56 +02:00
|
|
|
'process.env.NODE_ENV': "\"development\"",
|
2019-05-10 04:03:13 +02:00
|
|
|
}),
|
|
|
|
new webpack.ProvidePlugin({
|
|
|
|
// Automtically detect jQuery and $ as free var in modules
|
|
|
|
// and inject the jquery library
|
|
|
|
// This is required by many jquery plugins
|
2019-05-10 04:36:04 +02:00
|
|
|
// http://stackoverflow.com/questions/29080148/expose-jquery-to-real-window-object-with-webpack
|
2019-05-10 04:03:13 +02:00
|
|
|
jquery: "jquery",
|
|
|
|
jQuery: "jquery",
|
2021-04-30 05:52:56 +02:00
|
|
|
$: "jquery",
|
2019-05-10 04:03:13 +02:00
|
|
|
}),
|
|
|
|
],
|
2019-05-10 04:51:56 +02:00
|
|
|
entry: "./test/index.js",
|
2019-05-10 04:03:13 +02:00
|
|
|
target: "web",
|
|
|
|
devtool: "source-map",
|
2019-05-10 04:51:56 +02:00
|
|
|
output: {
|
|
|
|
path: path.resolve(__dirname, "./"),
|
|
|
|
filename: "test/test.bundle.js",
|
|
|
|
},
|
2019-05-10 04:03:13 +02:00
|
|
|
module: {
|
|
|
|
rules: [
|
|
|
|
{
|
|
|
|
test: /\.tsx?$/,
|
|
|
|
loader: 'ts-loader',
|
2021-04-30 05:52:56 +02:00
|
|
|
exclude: /node_modules/,
|
2019-05-10 04:03:13 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.(jsx)$/,
|
|
|
|
exclude: /node_modules/,
|
|
|
|
use: {
|
2021-04-30 05:52:56 +02:00
|
|
|
loader: "babel-loader",
|
|
|
|
},
|
2019-05-10 04:03:13 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.s?css$/,
|
2019-05-10 04:36:04 +02:00
|
|
|
loader: 'null-loader',
|
2019-05-10 04:03:13 +02:00
|
|
|
},
|
2021-04-30 05:52:56 +02:00
|
|
|
],
|
2019-05-10 04:03:13 +02:00
|
|
|
},
|
|
|
|
optimization: {
|
|
|
|
removeAvailableModules: true,
|
|
|
|
removeEmptyChunks: true,
|
|
|
|
mergeDuplicateChunks: true,
|
|
|
|
flagIncludedChunks: true,
|
|
|
|
occurrenceOrder: true,
|
|
|
|
sideEffects: true,
|
|
|
|
providedExports: true,
|
|
|
|
usedExports: true,
|
|
|
|
concatenateModules: false,
|
|
|
|
namedModules: false,
|
|
|
|
namedChunks: false,
|
|
|
|
minimize: false,
|
|
|
|
portableRecords: true,
|
|
|
|
splitChunks: {
|
|
|
|
cacheGroups: {
|
|
|
|
vendor: {
|
|
|
|
test: /[\\/]node_modules[\\/]/,
|
|
|
|
name: `tests/vendor`,
|
2021-04-30 05:52:56 +02:00
|
|
|
chunks: 'all',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-05-10 04:03:13 +02:00
|
|
|
},
|
|
|
|
resolve: {
|
|
|
|
extensions: [
|
|
|
|
".tsx",
|
|
|
|
".ts",
|
|
|
|
".js",
|
|
|
|
".jsx",
|
2021-04-30 05:52:56 +02:00
|
|
|
],
|
2019-05-10 04:03:13 +02:00
|
|
|
},
|
|
|
|
stats: statsConfig,
|
|
|
|
};
|
|
|
|
};
|