diff --git a/packages/next/build/webpack/config/blocks/css/loaders/global.ts b/packages/next/build/webpack/config/blocks/css/loaders/global.ts
index a5dcf146ff130..645d8b5545058 100644
--- a/packages/next/build/webpack/config/blocks/css/loaders/global.ts
+++ b/packages/next/build/webpack/config/blocks/css/loaders/global.ts
@@ -5,8 +5,8 @@ import { getClientStyleLoader } from './client'
export function getGlobalCssLoader(
ctx: ConfigurationContext,
- postCssPlugins: postcss.AcceptedPlugin[],
- preProcessors: webpack.RuleSetUseItem[] = []
+ postCssPlugins: readonly postcss.AcceptedPlugin[],
+ preProcessors: readonly webpack.RuleSetUseItem[] = []
): webpack.RuleSetUseItem[] {
const loaders: webpack.RuleSetUseItem[] = []
@@ -40,7 +40,7 @@ export function getGlobalCssLoader(
loaders.push(
// Webpack loaders run like a stack, so we need to reverse the natural
// order of preprocessors.
- ...preProcessors.reverse()
+ ...preProcessors.slice().reverse()
)
return loaders
diff --git a/packages/next/build/webpack/config/blocks/css/loaders/modules.ts b/packages/next/build/webpack/config/blocks/css/loaders/modules.ts
index 9069a1c9680f6..34e3c92057f31 100644
--- a/packages/next/build/webpack/config/blocks/css/loaders/modules.ts
+++ b/packages/next/build/webpack/config/blocks/css/loaders/modules.ts
@@ -6,8 +6,8 @@ import { getCssModuleLocalIdent } from './getCssModuleLocalIdent'
export function getCssModuleLoader(
ctx: ConfigurationContext,
- postCssPlugins: postcss.AcceptedPlugin[],
- preProcessors: webpack.RuleSetUseItem[] = []
+ postCssPlugins: readonly postcss.AcceptedPlugin[],
+ preProcessors: readonly webpack.RuleSetUseItem[] = []
): webpack.RuleSetUseItem[] {
const loaders: webpack.RuleSetUseItem[] = []
@@ -56,7 +56,7 @@ export function getCssModuleLoader(
loaders.push(
// Webpack loaders run like a stack, so we need to reverse the natural
// order of preprocessors.
- ...preProcessors.reverse()
+ ...preProcessors.slice().reverse()
)
return loaders
diff --git a/test/integration/scss-fixtures/loader-order/pages/_app.js b/test/integration/scss-fixtures/loader-order/pages/_app.js
new file mode 100644
index 0000000000000..b89fe16feb731
--- /dev/null
+++ b/test/integration/scss-fixtures/loader-order/pages/_app.js
@@ -0,0 +1,12 @@
+import React from 'react'
+import App from 'next/app'
+import '../styles/global.scss'
+
+class MyApp extends App {
+ render() {
+ const { Component, pageProps } = this.props
+ return