Skip to content

Commit 890f6fd

Browse files
committed
test: Update webpack configurations used on tests
1 parent 85463b3 commit 890f6fd

File tree

5 files changed

+84
-42
lines changed

5 files changed

+84
-42
lines changed

tests/webpack.config.app2.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
var config = require("./webpack.config.simple.js");
22
var BundleTracker = require('webpack-bundle-tracker');
3-
var ExtractTextPlugin = require("extract-text-webpack-plugin");
3+
var MiniCssExtractPlugin = require('mini-css-extract-plugin');
44

55
config.entry = {
66
app2: './assets/js/index'
77
};
88

99
config.plugins = [
10-
new ExtractTextPlugin("styles-app2.css"),
11-
new BundleTracker({filename: './webpack-stats-app2.json'})
10+
new MiniCssExtractPlugin(),
11+
new BundleTracker({path: __dirname, filename: './webpack-stats-app2.json'})
1212
];
1313

1414
module.exports = config;

tests/webpack.config.error.js

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
var path = require("path");
22
var webpack = require('webpack');
33
var BundleTracker = require('webpack-bundle-tracker');
4-
var ExtractTextPlugin = require("extract-text-webpack-plugin");
4+
var MiniCssExtractPlugin = require('mini-css-extract-plugin');
55

66

77
module.exports = {
@@ -13,20 +13,29 @@ module.exports = {
1313
},
1414

1515
plugins: [
16-
new ExtractTextPlugin("styles.css"),
17-
new BundleTracker({filename: './webpack-stats.json'}),
16+
new MiniCssExtractPlugin(),
17+
new BundleTracker({path: __dirname, filename: './webpack-stats.json'}),
1818
],
1919

2020
module: {
21-
loaders: [
21+
rules: [
2222
// we pass the output from babel loader to react-hot loader
23-
{ test: /\.jsx?$/, exclude: /node_modules/, loaders: ['babel'], },
24-
{ test: /\.css$/, loader: ExtractTextPlugin.extract("style-loader", "css-loader") }
23+
{
24+
test: /\.jsx?$/,
25+
exclude: /node_modules/,
26+
use: {
27+
loader: 'babel-loader',
28+
options: {
29+
presets: ['@babel/preset-react']
30+
}
31+
}
32+
},
33+
{ test: /\.css$/, use: [MiniCssExtractPlugin.loader, 'css-loader'], }
2534
],
2635
},
2736

2837
resolve: {
29-
modulesDirectories: ['node_modules', 'bower_components'],
30-
extensions: ['', '.js', '.jsx']
38+
modules: ['node_modules', 'bower_components'],
39+
extensions: ['.js', '.jsx']
3140
},
3241
}

tests/webpack.config.gzipTest.js

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
var path = require("path");
22
var webpack = require('webpack');
33
var BundleTracker = require('webpack-bundle-tracker');
4-
var ExtractTextPlugin = require("extract-text-webpack-plugin");
4+
var MiniCssExtractPlugin = require('mini-css-extract-plugin');
55

66

77
module.exports = {
@@ -13,20 +13,29 @@ module.exports = {
1313
},
1414

1515
plugins: [
16-
new ExtractTextPlugin("styles.css"),
17-
new BundleTracker({filename: './webpack-stats.json'}),
16+
new MiniCssExtractPlugin(),
17+
new BundleTracker({path: __dirname, filename: './webpack-stats.json'}),
1818
],
1919

2020
module: {
21-
loaders: [
21+
rules: [
2222
// we pass the output from babel loader to react-hot loader
23-
{ test: /\.jsx?$/, exclude: /node_modules/, loaders: ['babel'], },
24-
{ test: /\.css$/, loader: ExtractTextPlugin.extract("style-loader", "css-loader") }
23+
{
24+
test: /\.jsx?$/,
25+
exclude: /node_modules/,
26+
use: {
27+
loader: 'babel-loader',
28+
options: {
29+
presets: ['@babel/preset-react']
30+
}
31+
}
32+
},
33+
{ test: /\.css$/, use: [MiniCssExtractPlugin.loader, 'css-loader'], }
2534
],
2635
},
2736

2837
resolve: {
29-
modulesDirectories: ['node_modules', 'bower_components'],
30-
extensions: ['', '.js', '.jsx']
38+
modules: ['node_modules', 'bower_components'],
39+
extensions: ['.js', '.jsx']
3140
},
3241
}

tests/webpack.config.simple.js

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
var path = require("path");
22
var webpack = require('webpack');
33
var BundleTracker = require('webpack-bundle-tracker');
4-
var ExtractTextPlugin = require("extract-text-webpack-plugin");
4+
var MiniCssExtractPlugin = require('mini-css-extract-plugin');
55

66

77
module.exports = {
@@ -13,20 +13,29 @@ module.exports = {
1313
},
1414

1515
plugins: [
16-
new ExtractTextPlugin("styles.css"),
17-
new BundleTracker({filename: './webpack-stats.json'}),
16+
new MiniCssExtractPlugin(),
17+
new BundleTracker({path: __dirname, filename: './webpack-stats.json'}),
1818
],
1919

2020
module: {
21-
loaders: [
21+
rules: [
2222
// we pass the output from babel loader to react-hot loader
23-
{ test: /\.jsx?$/, exclude: /node_modules/, loaders: ['babel'], },
24-
{ test: /\.css$/, loader: ExtractTextPlugin.extract("style-loader", "css-loader") }
23+
{
24+
test: /\.jsx?$/,
25+
exclude: /node_modules/,
26+
use: {
27+
loader: 'babel-loader',
28+
options: {
29+
presets: ['@babel/preset-react']
30+
}
31+
}
32+
},
33+
{ test: /\.css$/, use: [MiniCssExtractPlugin.loader, 'css-loader'], }
2534
],
2635
},
2736

2837
resolve: {
29-
modulesDirectories: ['node_modules', 'bower_components'],
30-
extensions: ['', '.js', '.jsx']
38+
modules: ['node_modules', 'bower_components'],
39+
extensions: ['.js', '.jsx']
3140
},
3241
}

tests/webpack.config.split.js

Lines changed: 30 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
var path = require("path");
22
var webpack = require('webpack');
33
var BundleTracker = require('webpack-bundle-tracker');
4-
var SplitByPathPlugin = require('webpack-split-by-path');
5-
var ExtractTextPlugin = require("extract-text-webpack-plugin");
4+
var MiniCssExtractPlugin = require('mini-css-extract-plugin');
65

76

87
module.exports = {
@@ -15,26 +14,42 @@ module.exports = {
1514
},
1615

1716
plugins: [
18-
new ExtractTextPlugin("styles.css"),
19-
new BundleTracker({filename: './webpack-stats.json'}),
20-
new SplitByPathPlugin([
21-
{
22-
name: 'vendor',
23-
path: path.join(__dirname, '/node_modules/')
24-
}
25-
])
17+
new MiniCssExtractPlugin(),
18+
new BundleTracker({path: __dirname, filename: './webpack-stats.json'}),
2619
],
2720

2821
module: {
29-
loaders: [
22+
rules: [
3023
// we pass the output from babel loader to react-hot loader
31-
{ test: /\.jsx?$/, exclude: /node_modules/, loaders: ['babel'], },
32-
{ test: /\.css$/, loader: ExtractTextPlugin.extract("style-loader", "css-loader") }
24+
{
25+
test: /\.jsx?$/,
26+
exclude: /node_modules/,
27+
use: {
28+
loader: 'babel-loader',
29+
options: {
30+
presets: ['@babel/preset-react']
31+
}
32+
}
33+
},
34+
{ test: /\.css$/, use: [MiniCssExtractPlugin.loader, 'css-loader'], }
3335
],
3436
},
3537

3638
resolve: {
37-
modulesDirectories: ['node_modules', 'bower_components'],
38-
extensions: ['', '.js', '.jsx']
39+
modules: ['node_modules', 'bower_components'],
40+
extensions: ['.js', '.jsx']
3941
},
42+
43+
optimization: {
44+
splitChunks: {
45+
cacheGroups: {
46+
commons: {
47+
test: /[\\/]node_modules[\\/]/,
48+
name: 'vendors',
49+
chunks: 'all',
50+
enforce: true
51+
}
52+
}
53+
}
54+
}
4055
}

0 commit comments

Comments
 (0)