Skip to content

Commit

Permalink
fix(custom-webpack): fix loaders merge scenario (#909)
Browse files Browse the repository at this point in the history
  • Loading branch information
just-jeb authored Dec 16, 2020
1 parent 15f5f01 commit 0f0ad3d
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/custom-webpack/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,6 @@
"@angular-devkit/core": "^11.0.0",
"lodash": "^4.17.15",
"ts-node": "^9.0.0",
"webpack-merge": "^5.7.0"
"webpack-merge": "^5.7.2"
}
}
73 changes: 72 additions & 1 deletion packages/custom-webpack/src/webpack-config-merger.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { mergeConfigs } from './webpack-config-merger';
import * as webpack from 'webpack';
import { CustomizeRule } from 'webpack-merge';
import merge, { CustomizeRule } from 'webpack-merge';

describe('Webpack config merger test', () => {
it('Should replace plugins', () => {
Expand Down Expand Up @@ -235,4 +235,75 @@ describe('Webpack config merger test', () => {

expect(output).toEqual(expected);
});

it('should append loaders even if there is not intersection between configs', () => {
const conf1 = {
module: {
rules: [
{
test: '/\\.scss$|\\.sass$/',
use: [
{
loader: 'sass-loader',
options: {
sourceMap: true,
sassOptions: {
precision: 8,
outputStyle: 'expanded',
},
},
},
],
},
],
},
};
const conf2 = {
module: {
rules: [
{
test: '/\\.scss$|\\.sass$/',
use: [
{
loader: 'sass-resources-loader',
options: {
resources: ['src/styles/includes.scss'],
},
},
],
},
],
},
};

const expected = {
module: {
rules: [
{
test: '/\\.scss$|\\.sass$/',
use: [
{
loader: 'sass-loader',
options: {
sourceMap: true,
sassOptions: {
precision: 8,
outputStyle: 'expanded',
},
},
},
{
loader: 'sass-resources-loader',
options: {
resources: ['src/styles/includes.scss'],
},
},
],
},
],
},
};

expect(mergeConfigs(conf1, conf2)).toEqual(expected);
});
});

0 comments on commit 0f0ad3d

Please sign in to comment.