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

Commit

Permalink
Merge pull request #740 from Shopify/webpack-extend-test
Browse files Browse the repository at this point in the history
Add tests for 'webpack.config.extend.prod' and 'webpack.config.extend.dev'
  • Loading branch information
t-kelly authored Sep 11, 2018
2 parents d066c4a + 01c815b commit 4dff74a
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 4 deletions.
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'),
);
]);

0 comments on commit 4dff74a

Please sign in to comment.