Skip to content

Commit

Permalink
Don't process inline <style> elements as CSS modules (#7921)
Browse files Browse the repository at this point in the history
  • Loading branch information
devongovett committed Apr 8, 2022
1 parent 63f2a97 commit 39b330e
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 3 deletions.
11 changes: 11 additions & 0 deletions packages/core/integration-tests/test/css-modules.js
Expand Up @@ -610,4 +610,15 @@ describe('css modules', () => {
},
]);
});

it('should not process inline <style> elements as a CSS module', async function () {
await bundle(
path.join(__dirname, '/integration/css-modules-style/index.html'),
);
let contents = await outputFS.readFile(
path.join(distDir, 'index.html'),
'utf8',
);
assert(contents.includes('.index {'));
});
});
@@ -0,0 +1,6 @@
<!DOCTYPE html>
<style>
.index {
color: red;
}
</style>
@@ -0,0 +1,6 @@
{
"private": true,
"@parcel/transformer-css": {
"cssModules": true
}
}
Empty file.
7 changes: 4 additions & 3 deletions packages/transformers/css/src/CSSTransformer.js
Expand Up @@ -53,9 +53,10 @@ export default (new Transformer({
filename: path.relative(options.projectRoot, asset.filePath),
code,
cssModules:
config?.cssModules ??
(asset.meta.cssModulesCompiled == null &&
/\.module\./.test(asset.filePath)),
asset.meta.type !== 'tag' &&
(config?.cssModules ??
(asset.meta.cssModulesCompiled == null &&
/\.module\./.test(asset.filePath))),
analyzeDependencies: asset.meta.hasDependencies !== false,
sourceMap: !!asset.env.sourceMap,
drafts: config?.drafts,
Expand Down

0 comments on commit 39b330e

Please sign in to comment.