Skip to content
This repository has been archived by the owner on Jul 19, 2021. It is now read-only.

Add tests for 'webpack.config.extend.prod' and 'webpack.config.extend.dev' #740

Merged
merged 1 commit into from
Sep 11, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions packages/slate-tools/tools/webpack/config/__tests__/dev.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
test(`merges contents of 'webpack.config.extend.dev' into webpack config`, () => {
global.slateUserConfig = {
'webpack.config.extend.dev': {some: 'value'},
};

jest.mock('../core', () => {
return {entry: {}};
});
jest.mock('webpack-merge');
jest.mock('../../entrypoints', () => {
return {
templateFiles: jest.fn(),
layoutFiles: jest.fn(),
};
});

const merge = require('webpack-merge');
require('../dev');

expect(merge).toBeCalledWith(
expect.arrayContaining([
global.slateUserConfig['webpack.config.extend.dev'],
]),
);
});
26 changes: 26 additions & 0 deletions packages/slate-tools/tools/webpack/config/__tests__/prod.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
test(`merges contents of 'webpack.config.extend.prod' into webpack config`, () => {
global.slateUserConfig = {
'webpack.config.extend.prod': {some: 'value'},
};

jest.mock('../core', () => {
return {entry: {}};
});
jest.mock('webpack-merge');
jest.mock('../../entrypoints', () => {
return {
templateFiles: jest.fn(),
layoutFiles: jest.fn(),
};
});

const merge = require('webpack-merge');

require('../prod');

expect(merge).toBeCalledWith(
expect.arrayContaining([
global.slateUserConfig['webpack.config.extend.prod'],
]),
);
});
4 changes: 2 additions & 2 deletions packages/slate-tools/tools/webpack/config/dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Object.keys(webpackCoreConfig.entry).forEach((name) => {
].concat(webpackCoreConfig.entry[name]);
});

module.exports = merge(
module.exports = merge([
webpackCoreConfig,
babel,
{
Expand Down Expand Up @@ -110,4 +110,4 @@ module.exports = merge(
],
},
config.get('webpack.config.extend.dev'),
);
]);
4 changes: 2 additions & 2 deletions packages/slate-tools/tools/webpack/config/prod.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const {templateFiles, layoutFiles} = require('../entrypoints');
const HtmlWebpackIncludeLiquidStylesPlugin = require('../html-webpack-include-chunks');
const config = new SlateConfig(require('../../../slate-tools.schema'));

module.exports = merge(
module.exports = merge([
webpackCoreConfig,
babel,
sass,
Expand Down Expand Up @@ -110,4 +110,4 @@ module.exports = merge(
},
},
config.get('webpack.config.extend.prod'),
);
]);