diff --git a/test/optimization/index.js b/test/optimization/index.js new file mode 100644 index 00000000000..c56f17c89e9 --- /dev/null +++ b/test/optimization/index.js @@ -0,0 +1 @@ +console.log("Bokuto") diff --git a/test/optimization/optimization.test.js b/test/optimization/optimization.test.js new file mode 100644 index 00000000000..5cc52e669be --- /dev/null +++ b/test/optimization/optimization.test.js @@ -0,0 +1,20 @@ +const fs = require('fs'); +const { join } = require('path'); +const { version } = require('webpack'); +const { run } = require('../utils/test-utils'); + +describe('optimization option in config', () => { + it('should work with mangleExports disabled', () => { + const { stdout, stderr } = run(__dirname, [], false); + // Should throw when webpack is less than 5 + if (!version.startsWith('5')) { + expect(stderr).toContain("configuration.optimization has an unknown property 'mangleExports'"); + } else { + // Should apply the provided optimization to the compiler + expect(stdout).toContain('mangleExports: false'); + // check that the output file exists + expect(fs.existsSync(join(__dirname, '/dist/main.js'))).toBeTruthy(); + expect(stderr).toBeFalsy(); + } + }); +}); diff --git a/test/optimization/webpack.config.js b/test/optimization/webpack.config.js new file mode 100644 index 00000000000..c5ddd675368 --- /dev/null +++ b/test/optimization/webpack.config.js @@ -0,0 +1,8 @@ +const WebpackCLITestPlugin = require('../utils/webpack-cli-test-plugin'); + +module.exports = { + plugins: [new WebpackCLITestPlugin()], + optimization: { + mangleExports: false, + }, +};