|
1 | 1 | const webpack = require('webpack');
|
2 | 2 | const HtmlWebpackPlugin = require('html-webpack-plugin');
|
3 |
| -const NodePolyfillPlugin = require("node-polyfill-webpack-plugin"); |
| 3 | +const NodePolyfillPlugin = require('node-polyfill-webpack-plugin'); |
4 | 4 | const MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
5 | 5 | const path = require('path');
|
6 | 6 |
|
7 | 7 | module.exports = env => ({
|
8 |
| - mode: 'development', |
9 |
| - entry: path.resolve(__dirname, './webpack-tests.js'), |
10 |
| - resolve: { |
11 |
| - alias: { |
12 |
| - 'fsProvider': path.resolve(__dirname, '../shims/providers/default'), |
13 |
| - }, |
| 8 | + mode: 'development', |
| 9 | + entry: path.resolve(__dirname, './webpack-tests.js'), |
| 10 | + resolve: { |
| 11 | + alias: { |
| 12 | + 'fsProvider': path.resolve(__dirname, '../shims/providers/default'), |
14 | 13 | },
|
15 |
| - output: { |
16 |
| - path: path.resolve(__dirname, './dist-webpack'), |
17 |
| - filename: 'index.js', |
18 |
| - }, |
19 |
| - plugins: [ |
20 |
| - new webpack.ContextReplacementPlugin( |
21 |
| - // Mocha safely uses require in such a way that webpack cannot statically extract dependancies. |
22 |
| - // If the ignoreRequestDependancyExpressionWarnings env is set, we will aggregate these warnings |
23 |
| - // into one summary warning to minimise spamming the console. |
24 |
| - /\/node_modules\/mocha\/lib/, |
25 |
| - (data) => { |
26 |
| - if (env.ignoreRequestDependancyExpressionWarnings) { |
27 |
| - let requestDependencyExpressionsIgnored = 0; |
28 |
| - data.dependencies.forEach((dependancy) => { |
29 |
| - if (dependancy.critical === 'the request of a dependency is an expression') { |
30 |
| - dependancy.critical = undefined; |
31 |
| - requestDependencyExpressionsIgnored += 1; |
32 |
| - } |
33 |
| - }); |
34 |
| - console.log(`WARNING: Ignoring ${requestDependencyExpressionsIgnored} "request of a dependency is an expression" warnings from "node_modules/mocha/lib".`); |
35 |
| - } |
36 |
| - return data; |
37 |
| - }, |
38 |
| - ), |
39 |
| - new NodePolyfillPlugin(), |
40 |
| - new MiniCssExtractPlugin(), |
41 |
| - new HtmlWebpackPlugin({ |
42 |
| - title: 'Filer Tests - Webpack Build', |
43 |
| - template: './tests/webpack.index.html', |
44 |
| - }), |
| 14 | + }, |
| 15 | + output: { |
| 16 | + path: path.resolve(__dirname, './dist-webpack'), |
| 17 | + filename: 'index.js', |
| 18 | + }, |
| 19 | + plugins: [ |
| 20 | + new webpack.ContextReplacementPlugin( |
| 21 | + // Mocha safely uses require in such a way that webpack cannot statically extract dependancies. |
| 22 | + // If the ignoreRequestDependancyExpressionWarnings env is set, we will aggregate these warnings |
| 23 | + // into one summary warning to minimise spamming the console. |
| 24 | + /\/node_modules\/mocha\/lib/, |
| 25 | + (data) => { |
| 26 | + if (env.ignoreRequestDependancyExpressionWarnings) { |
| 27 | + let requestDependencyExpressionsIgnored = 0; |
| 28 | + data.dependencies.forEach((dependancy) => { |
| 29 | + if (dependancy.critical === 'the request of a dependency is an expression') { |
| 30 | + dependancy.critical = undefined; |
| 31 | + requestDependencyExpressionsIgnored += 1; |
| 32 | + } |
| 33 | + }); |
| 34 | + console.log(`WARNING: Ignoring ${requestDependencyExpressionsIgnored} "request of a dependency is an expression" warnings from "node_modules/mocha/lib".`); |
| 35 | + } |
| 36 | + return data; |
| 37 | + }, |
| 38 | + ), |
| 39 | + new NodePolyfillPlugin(), |
| 40 | + new MiniCssExtractPlugin(), |
| 41 | + new HtmlWebpackPlugin({ |
| 42 | + title: 'Filer Tests - Webpack Build', |
| 43 | + template: './tests/webpack.index.html', |
| 44 | + }), |
| 45 | + ], |
| 46 | + module: { |
| 47 | + rules: [ |
| 48 | + { |
| 49 | + test: /\.css$/i, |
| 50 | + use: [MiniCssExtractPlugin.loader, 'css-loader'], |
| 51 | + }, |
45 | 52 | ],
|
46 |
| - module: { |
47 |
| - rules: [ |
48 |
| - { |
49 |
| - test: /\.css$/i, |
50 |
| - use: [MiniCssExtractPlugin.loader, 'css-loader'], |
51 |
| - }, |
52 |
| - ], |
53 |
| - }, |
54 |
| - optimization: { |
55 |
| - minimize: false, |
56 |
| - }, |
57 |
| - devtool: 'inline-source-map', |
58 |
| - devServer: { |
59 |
| - contentBase: path.resolve(__dirname, './dist-webpack'), |
60 |
| - } |
| 53 | + }, |
| 54 | + optimization: { |
| 55 | + minimize: false, |
| 56 | + }, |
| 57 | + devtool: 'inline-source-map', |
| 58 | + devServer: { |
| 59 | + contentBase: path.resolve(__dirname, './dist-webpack'), |
| 60 | + } |
61 | 61 | });
|
0 commit comments