diff --git a/lib/craco-less.dev.test.js b/lib/craco-less.dev.test.js index 3bcfdfe..db48a72 100644 --- a/lib/craco-less.dev.test.js +++ b/lib/craco-less.dev.test.js @@ -55,12 +55,15 @@ test("the webpack config is modified correctly without any options", () => { expect(lessRule.use[1].loader).toContain(`${path.sep}css-loader`); expect(lessRule.use[1].options).toEqual({ importLoaders: 3, + modules: { + mode: "icss", + }, sourceMap: webpackConfig.devtool !== false, }); expect(lessRule.use[2].loader).toContain(`${path.sep}postcss-loader`); - expect(lessRule.use[2].options.ident).toEqual("postcss"); - expect(lessRule.use[2].options.plugins).not.toBeUndefined(); + expect(lessRule.use[2].options.postcssOptions.ident).toEqual("postcss"); + expect(lessRule.use[2].options.postcssOptions.plugins).not.toBeUndefined(); expect(lessRule.use[3].loader).toContain(`${path.sep}resolve-url-loader`); expect(lessRule.use[3].options).toEqual({ @@ -81,15 +84,18 @@ test("the webpack config is modified correctly without any options", () => { expect(lessModuleRule.use[1].loader).toContain(`${path.sep}css-loader`); expect(lessModuleRule.use[1].options).toEqual({ importLoaders: 3, - sourceMap: webpackConfig.devtool !== false, modules: { getLocalIdent: getCSSModuleLocalIdent, + mode: "local", }, + sourceMap: webpackConfig.devtool !== false, }); expect(lessModuleRule.use[2].loader).toContain(`${path.sep}postcss-loader`); - expect(lessModuleRule.use[2].options.ident).toEqual("postcss"); - expect(lessModuleRule.use[2].options.plugins).not.toBeUndefined(); + expect(lessModuleRule.use[2].options.postcssOptions.ident).toEqual("postcss"); + expect( + lessModuleRule.use[2].options.postcssOptions.plugins + ).not.toBeUndefined(); expect(lessModuleRule.use[3].loader).toContain( `${path.sep}resolve-url-loader` @@ -144,12 +150,15 @@ test("the webpack config is modified correctly without any options on Windows", expect(lessRule.use[1].loader).toContain("\\css-loader"); expect(lessRule.use[1].options).toEqual({ importLoaders: 3, + modules: { + mode: "icss", + }, sourceMap: webpackConfig.devtool !== false, }); expect(lessRule.use[2].loader).toContain("\\postcss-loader"); - expect(lessRule.use[2].options.ident).toEqual("postcss"); - expect(lessRule.use[2].options.plugins).not.toBeUndefined(); + expect(lessRule.use[2].options.postcssOptions.ident).toEqual("postcss"); + expect(lessRule.use[2].options.postcssOptions.plugins).not.toBeUndefined(); expect(lessRule.use[3].loader).toContain(`\\resolve-url-loader`); expect(lessRule.use[3].options).toEqual({ @@ -174,12 +183,15 @@ test("the webpack config is modified correctly without any options on Windows", sourceMap: webpackConfig.devtool !== false, modules: { getLocalIdent: getCSSModuleLocalIdent, + mode: "local", }, }); expect(lessModuleRule.use[2].loader).toContain("\\postcss-loader"); - expect(lessModuleRule.use[2].options.ident).toEqual("postcss"); - expect(lessModuleRule.use[2].options.plugins).not.toBeUndefined(); + expect(lessModuleRule.use[2].options.postcssOptions.ident).toEqual("postcss"); + expect( + lessModuleRule.use[2].options.postcssOptions.plugins + ).not.toBeUndefined(); expect(lessModuleRule.use[3].loader).toContain(`\\resolve-url-loader`); expect(lessModuleRule.use[3].options).toEqual({ @@ -217,8 +229,8 @@ test("the webpack config is modified correctly with less-loader options", () => expect(lessRule).not.toBeUndefined(); expect(lessRule.use[2].loader).toContain(`${path.sep}postcss-loader`); - expect(lessRule.use[2].options.ident).toEqual("postcss"); - expect(lessRule.use[2].options.plugins).not.toBeUndefined(); + expect(lessRule.use[2].options.postcssOptions.ident).toEqual("postcss"); + expect(lessRule.use[2].options.postcssOptions.plugins).not.toBeUndefined(); expect(lessRule.use[3].loader).toContain(`${path.sep}resolve-url-loader`); expect(lessRule.use[3].options).toEqual({ @@ -241,8 +253,10 @@ test("the webpack config is modified correctly with less-loader options", () => expect(lessModuleRule).not.toBeUndefined(); expect(lessModuleRule.use[2].loader).toContain(`${path.sep}postcss-loader`); - expect(lessModuleRule.use[2].options.ident).toEqual("postcss"); - expect(lessModuleRule.use[2].options.plugins).not.toBeUndefined(); + expect(lessModuleRule.use[2].options.postcssOptions.ident).toEqual("postcss"); + expect( + lessModuleRule.use[2].options.postcssOptions.plugins + ).not.toBeUndefined(); expect(lessModuleRule.use[3].loader).toContain( `${path.sep}resolve-url-loader` @@ -312,8 +326,8 @@ test("the webpack config is modified correctly with all loader options", () => { }); expect(lessRule.use[2].loader).toContain(`${path.sep}postcss-loader`); - expect(lessRule.use[2].options.ident).toEqual("test-ident"); - expect(lessRule.use[2].options.plugins).not.toBeUndefined(); + expect(lessRule.use[2].options.postcssOptions.ident).toEqual("test-ident"); + expect(lessRule.use[2].options.postcssOptions.plugins).not.toBeUndefined(); expect(lessRule.use[3].loader).toContain(`${path.sep}resolve-url-loader`); expect(lessRule.use[3].options).toEqual({ @@ -348,8 +362,12 @@ test("the webpack config is modified correctly with all loader options", () => { }); expect(lessModuleRule.use[2].loader).toContain(`${path.sep}postcss-loader`); - expect(lessModuleRule.use[2].options.ident).toEqual("test-ident"); - expect(lessModuleRule.use[2].options.plugins).not.toBeUndefined(); + expect(lessModuleRule.use[2].options.postcssOptions.ident).toEqual( + "test-ident" + ); + expect( + lessModuleRule.use[2].options.postcssOptions.plugins + ).not.toBeUndefined(); expect(lessModuleRule.use[3].loader).toContain( `${path.sep}resolve-url-loader` @@ -399,8 +417,8 @@ test("the webpack config is modified correctly with the modifyLessRule option", expect(lessRule.use[0].options.testOption).toEqual("test-value-development"); expect(lessRule.use[2].loader).toContain(`${path.sep}postcss-loader`); - expect(lessRule.use[2].options.ident).toEqual("postcss"); - expect(lessRule.use[2].options.plugins).not.toBeUndefined(); + expect(lessRule.use[2].options.postcssOptions.ident).toEqual("postcss"); + expect(lessRule.use[2].options.postcssOptions.plugins).not.toBeUndefined(); expect(lessRule.use[3].loader).toContain(`${path.sep}resolve-url-loader`); expect(lessRule.use[3].options).toEqual({ @@ -452,8 +470,10 @@ test("the webpack config is modified correctly with the modifyLessModuleRule opt ); expect(lessModuleRule.use[2].loader).toContain(`${path.sep}postcss-loader`); - expect(lessModuleRule.use[2].options.ident).toEqual("postcss"); - expect(lessModuleRule.use[2].options.plugins).not.toBeUndefined(); + expect(lessModuleRule.use[2].options.postcssOptions.ident).toEqual("postcss"); + expect( + lessModuleRule.use[2].options.postcssOptions.plugins + ).not.toBeUndefined(); expect(lessModuleRule.use[3].loader).toContain( `${path.sep}resolve-url-loader` diff --git a/lib/craco-less.prod.test.js b/lib/craco-less.prod.test.js index 8e3bd6c..01808b0 100644 --- a/lib/craco-less.prod.test.js +++ b/lib/craco-less.prod.test.js @@ -57,12 +57,15 @@ test("the webpack config is modified correctly without any options", () => { expect(lessRule.use[1].loader).toContain(`${path.sep}css-loader`); expect(lessRule.use[1].options).toEqual({ importLoaders: 3, + modules: { + mode: "icss", + }, sourceMap: true, }); expect(lessRule.use[2].loader).toContain(`${path.sep}postcss-loader`); - expect(lessRule.use[2].options.ident).toEqual("postcss"); - expect(lessRule.use[2].options.plugins).not.toBeUndefined(); + expect(lessRule.use[2].options.postcssOptions.ident).toEqual("postcss"); + expect(lessRule.use[2].options.postcssOptions.plugins).not.toBeUndefined(); expect(lessRule.use[3].loader).toContain(`${path.sep}resolve-url-loader`); expect(lessRule.use[3].options).toEqual({ @@ -90,12 +93,15 @@ test("the webpack config is modified correctly without any options", () => { sourceMap: true, modules: { getLocalIdent: getCSSModuleLocalIdent, + mode: "local", }, }); expect(lessModuleRule.use[2].loader).toContain(`${path.sep}postcss-loader`); - expect(lessModuleRule.use[2].options.ident).toEqual("postcss"); - expect(lessModuleRule.use[2].options.plugins).not.toBeUndefined(); + expect(lessModuleRule.use[2].options.postcssOptions.ident).toEqual("postcss"); + expect( + lessModuleRule.use[2].options.postcssOptions.plugins + ).not.toBeUndefined(); expect(lessModuleRule.use[3].loader).toContain( `${path.sep}resolve-url-loader` @@ -152,12 +158,15 @@ test("the webpack config is modified correctly without any options on Windows", expect(lessRule.use[1].loader).toContain("\\css-loader"); expect(lessRule.use[1].options).toEqual({ importLoaders: 3, + modules: { + mode: "icss", + }, sourceMap: true, }); expect(lessRule.use[2].loader).toContain("\\postcss-loader"); - expect(lessRule.use[2].options.ident).toEqual("postcss"); - expect(lessRule.use[2].options.plugins).not.toBeUndefined(); + expect(lessRule.use[2].options.postcssOptions.ident).toEqual("postcss"); + expect(lessRule.use[2].options.postcssOptions.plugins).not.toBeUndefined(); expect(lessRule.use[3].loader).toContain(`\\resolve-url-loader`); expect(lessRule.use[3].options).toEqual({ @@ -182,12 +191,15 @@ test("the webpack config is modified correctly without any options on Windows", sourceMap: true, modules: { getLocalIdent: getCSSModuleLocalIdent, + mode: "local", }, }); expect(lessModuleRule.use[2].loader).toContain("\\postcss-loader"); - expect(lessModuleRule.use[2].options.ident).toEqual("postcss"); - expect(lessModuleRule.use[2].options.plugins).not.toBeUndefined(); + expect(lessModuleRule.use[2].options.postcssOptions.ident).toEqual("postcss"); + expect( + lessModuleRule.use[2].options.postcssOptions.plugins + ).not.toBeUndefined(); expect(lessModuleRule.use[3].loader).toContain(`\\resolve-url-loader`); expect(lessModuleRule.use[3].options).toEqual({ @@ -225,8 +237,8 @@ test("the webpack config is modified correctly with less-loader options", () => expect(lessRule).not.toBeUndefined(); expect(lessRule.use[2].loader).toContain(`${path.sep}postcss-loader`); - expect(lessRule.use[2].options.ident).toEqual("postcss"); - expect(lessRule.use[2].options.plugins).not.toBeUndefined(); + expect(lessRule.use[2].options.postcssOptions.ident).toEqual("postcss"); + expect(lessRule.use[2].options.postcssOptions.plugins).not.toBeUndefined(); expect(lessRule.use[3].loader).toContain(`${path.sep}resolve-url-loader`); expect(lessRule.use[3].options).toEqual({ @@ -249,8 +261,10 @@ test("the webpack config is modified correctly with less-loader options", () => expect(lessModuleRule).not.toBeUndefined(); expect(lessModuleRule.use[2].loader).toContain(`${path.sep}postcss-loader`); - expect(lessModuleRule.use[2].options.ident).toEqual("postcss"); - expect(lessModuleRule.use[2].options.plugins).not.toBeUndefined(); + expect(lessModuleRule.use[2].options.postcssOptions.ident).toEqual("postcss"); + expect( + lessModuleRule.use[2].options.postcssOptions.plugins + ).not.toBeUndefined(); expect(lessModuleRule.use[3].loader).toContain( `${path.sep}resolve-url-loader` @@ -320,10 +334,9 @@ test("the webpack config is modified correctly with all loader options", () => { localIdentName: "[local]_[hash:base64:5]", sourceMap: true, }); - expect(lessRule.use[2].loader).toContain(`${path.sep}postcss-loader`); - expect(lessRule.use[2].options.ident).toEqual("test-ident"); - expect(lessRule.use[2].options.plugins).not.toBeUndefined(); + expect(lessRule.use[2].options.postcssOptions.ident).toEqual("test-ident"); + expect(lessRule.use[2].options.postcssOptions.plugins).not.toBeUndefined(); expect(lessRule.use[3].loader).toContain(`${path.sep}resolve-url-loader`); expect(lessRule.use[3].options).toEqual({ @@ -360,8 +373,12 @@ test("the webpack config is modified correctly with all loader options", () => { }); expect(lessModuleRule.use[2].loader).toContain(`${path.sep}postcss-loader`); - expect(lessModuleRule.use[2].options.ident).toEqual("test-ident"); - expect(lessModuleRule.use[2].options.plugins).not.toBeUndefined(); + expect(lessModuleRule.use[2].options.postcssOptions.ident).toEqual( + "test-ident" + ); + expect( + lessModuleRule.use[2].options.postcssOptions.plugins + ).not.toBeUndefined(); expect(lessModuleRule.use[3].loader).toContain( `${path.sep}resolve-url-loader` @@ -413,8 +430,8 @@ test("the webpack config is modified correctly with the modifyLessRule option", expect(lessRule.use[0].options.testOption).toEqual("test-value-production"); expect(lessRule.use[2].loader).toContain(`${path.sep}postcss-loader`); - expect(lessRule.use[2].options.ident).toEqual("postcss"); - expect(lessRule.use[2].options.plugins).not.toBeUndefined(); + expect(lessRule.use[2].options.postcssOptions.ident).toEqual("postcss"); + expect(lessRule.use[2].options.postcssOptions.plugins).not.toBeUndefined(); expect(lessRule.use[3].loader).toContain(`${path.sep}resolve-url-loader`); expect(lessRule.use[3].options).toEqual({ @@ -470,8 +487,10 @@ test("the webpack config is modified correctly with the modifyLessModuleRule opt ); expect(lessModuleRule.use[2].loader).toContain(`${path.sep}postcss-loader`); - expect(lessModuleRule.use[2].options.ident).toEqual("postcss"); - expect(lessModuleRule.use[2].options.plugins).not.toBeUndefined(); + expect(lessModuleRule.use[2].options.postcssOptions.ident).toEqual("postcss"); + expect( + lessModuleRule.use[2].options.postcssOptions.plugins + ).not.toBeUndefined(); expect(lessModuleRule.use[3].loader).toContain( `${path.sep}resolve-url-loader`