-
Notifications
You must be signed in to change notification settings - Fork 27k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
95 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
test/integration/css-fixtures/custom-configuration-webpack/next.config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
module.exports = { | ||
onDemandEntries: { | ||
maxInactiveAge: 1000 * 60 * 60, | ||
}, | ||
webpack(config) { | ||
modifyLoaderConfig( | ||
config.module.rules, | ||
[/(?<!\.module)\.css$/, /\.module\.css$/], | ||
(rule) => { | ||
if (!Array.isArray(rule.use)) return | ||
rule.use.forEach((u) => { | ||
if (u.options.postcssOptions) { | ||
u.options.postcssOptions.plugins = [ | ||
require('postcss-short-size')({ | ||
// Add a prefix to test that configuration is passed | ||
prefix: 'xyz', | ||
}), | ||
] | ||
} | ||
}) | ||
} | ||
) | ||
|
||
return config | ||
}, | ||
future: { strictPostcssConfiguration: true }, | ||
} | ||
|
||
function modifyLoaderConfig(rules, regexes, cb) { | ||
rules.forEach((rule) => { | ||
if (rule.oneOf) return modifyLoaderConfig(rule.oneOf, regexes, cb) | ||
regexes.forEach((regex) => { | ||
if (rule.test && rule.test.toString() === regex.toString()) cb(rule) | ||
}) | ||
}) | ||
} |
12 changes: 12 additions & 0 deletions
12
test/integration/css-fixtures/custom-configuration-webpack/pages/_app.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import React from 'react' | ||
import App from 'next/app' | ||
import '../styles/global.css' | ||
|
||
class MyApp extends App { | ||
render() { | ||
const { Component, pageProps } = this.props | ||
return <Component {...pageProps} /> | ||
} | ||
} | ||
|
||
export default MyApp |
3 changes: 3 additions & 0 deletions
3
test/integration/css-fixtures/custom-configuration-webpack/pages/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export default function Home() { | ||
return <div /> | ||
} |
11 changes: 11 additions & 0 deletions
11
test/integration/css-fixtures/custom-configuration-webpack/styles/global.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/* this should pass through untransformed */ | ||
@media (480px <= width < 768px) { | ||
::placeholder { | ||
color: green; | ||
} | ||
} | ||
|
||
/* this should be transformed to width/height */ | ||
.video { | ||
-xyz-max-size: 400px 300px; | ||
} |