diff --git a/config/webpack.dev-stage.config.js b/config/webpack.dev-stage.config.js index e6c3f86e6..001ba145e 100644 --- a/config/webpack.dev-stage.config.js +++ b/config/webpack.dev-stage.config.js @@ -102,7 +102,7 @@ module.exports = merge(commonConfig, { ], // Silences compiler deprecation warnings. They mostly come from bootstrap and/or paragon. quietDeps: true, - silenceDeprecations: ['abs-percent', 'color-functions', 'import', 'mixed-decls', 'global-builtin'], + silenceDeprecations: ['abs-percent', 'color-functions', 'import', 'mixed-decls', 'global-builtin', 'legacy-js-api'], }, }, }, diff --git a/config/webpack.dev.config.js b/config/webpack.dev.config.js index c1376eb65..9dc4fea52 100644 --- a/config/webpack.dev.config.js +++ b/config/webpack.dev.config.js @@ -31,16 +31,18 @@ resolvePrivateEnvConfig('.env.private'); const aliases = getLocalAliases(); const PUBLIC_PATH = process.env.PUBLIC_PATH || '/'; -function getStyleUseConfig() { +function getStyleUseConfig({ isModule = false } = {}) { + const cssLoaderOptions = { + sourceMap: true, + ...(isModule + ? { modules: true } + : { modules: { compileType: 'icss' } } + ), + }; return [ { loader: 'css-loader', // translates CSS into CommonJS - options: { - sourceMap: true, - modules: { - compileType: 'icss', - }, - }, + options: cssLoaderOptions, }, { loader: 'postcss-loader', @@ -66,7 +68,7 @@ function getStyleUseConfig() { ], // Silences compiler deprecation warnings. They mostly come from bootstrap and/or paragon. quietDeps: true, - silenceDeprecations: ['abs-percent', 'color-functions', 'import', 'mixed-decls', 'global-builtin'], + silenceDeprecations: ['abs-percent', 'color-functions', 'import', 'mixed-decls', 'global-builtin', 'legacy-js-api'], }, }, }, @@ -118,6 +120,13 @@ module.exports = merge(commonConfig, { ...getStyleUseConfig(), ], }, + { + resource: /\.module\.(scss|css)$/, + use: [ + 'style-loader', // creates style nodes from JS strings + ...getStyleUseConfig({ isModule: true }), + ], + }, { use: [ 'style-loader', // creates style nodes from JS strings diff --git a/config/webpack.prod.config.js b/config/webpack.prod.config.js index 4c8079cc4..2f05591c0 100644 --- a/config/webpack.prod.config.js +++ b/config/webpack.prod.config.js @@ -133,7 +133,7 @@ module.exports = merge(commonConfig, { ], // Silences compiler deprecation warnings. They mostly come from bootstrap and/or paragon. quietDeps: true, - silenceDeprecations: ['abs-percent', 'color-functions', 'import', 'mixed-decls', 'global-builtin'], + silenceDeprecations: ['abs-percent', 'color-functions', 'import', 'mixed-decls', 'global-builtin', 'legacy-js-api'], }, }, }, diff --git a/example/src/App.tsx b/example/src/App.tsx index 5aed15f95..31b4ff91f 100644 --- a/example/src/App.tsx +++ b/example/src/App.tsx @@ -6,16 +6,40 @@ import appleUrl, { ReactComponent as Apple } from './apple.svg'; // @ts-ignore import appleImg from './apple.jpg'; -import './style.scss'; import ParagonPreview from './ParagonPreview'; +// Without CSS modules support +// @ts-ignore +import defaultStyles from './style.scss'; + +// With CSS modules support +// @ts-ignore +import moduleStyles from './example.module.scss'; + +// @ts-ignore +import exampleStyles from './example.scss'; + +console.log('defaultStyles', defaultStyles); +console.log('moduleStyles', moduleStyles); +console.log('exampleStyles', exampleStyles); + const App = () => { const newEnglandApples = ['macintosh', 'granny smith']; const allApples = [...newEnglandApples, 'fuji', 'golden delicious']; + + const stylesConfig = { + defaultStyles, + moduleStyles, + exampleStyles, + }; + return (
+ {JSON.stringify(stylesConfig, null, 2)}
+
env.config.js integer test: {Number.isInteger(config.INTEGER_VALUE) ? 'It was an integer. Great.' : 'It was not an integer! Why not? '}
I'm aligned right, but left in RTL.
+ {/*I'm aligned right, but left in RTL.
*/} + {/*I'm aligned right, but left in RTL.
+I'm aligned right, but left in RTL.
*/}