Skip to content

Commit

Permalink
chore: Add test with split chunks enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
danez committed Nov 6, 2021
1 parent fb21f21 commit 438589b
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
const path = require('path');
const webpack = require('webpack');
const loadGruntWebpackTasks = require('../../../../utils/loadGruntWebpackTasks');

module.exports = function (grunt) {
grunt.initConfig({
webpack: {
test: {
mode: "none",
entry: path.join(__dirname, "entry"),
output: {
path: __dirname,
filename: "[name].bundle.js",
},
plugins: [
new webpack.DefinePlugin({ okey: JSON.stringify("dokey") }),
],
optimization: {
splitChunks: {
cacheGroups: {
common: {
test: function (module) {
if (module.resource) {
return module.resource.includes('/uniquerandomfolder/');
}
},
name: 'common',
minChunks: 1,
minSize: 0,
chunks: 'all'
}
}
}
}
},
},
});

loadGruntWebpackTasks(grunt);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
require("./uniquerandomfolder/file");
console.log(okey);
10 changes: 10 additions & 0 deletions tests/integration/fixtures/webpack/split-chunks-issue-169/exec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
assertGrunt.success();

const content = fs.readFileSync(path.join(cwd, 'main.bundle.js'), 'utf-8');
expect(content).toMatch(/console\.log\("dokey"\)/);

// stats should be displayed by default
expect(stdout).toMatch(/\[emitted\]/);
expect(stdout).toMatch(/main\.bundle\.js/);
expect(stdout).toMatch(/common\.bundle\.js/);

Empty file.

0 comments on commit 438589b

Please sign in to comment.