Created
November 29, 2019 14:43
-
-
Save Vittly/4244ff8b65b864674ed1739144e23386 to your computer and use it in GitHub Desktop.
SplitChunksPlugin-doesnt-play-with-postcss-imports
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
.Bar { | |
color: yellow; | |
} |
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
import React from "react"; | |
import "./Bar.scss"; | |
export const Bar: React.FC = () => <i className="Bar">Bar</i>; |
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
import './Foo.scss'; |
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
@import './Bar.scss'; | |
.Foo { | |
background-color: green; | |
} |
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
import React from "react"; | |
import { Bar } from "./Bar"; | |
import "./Foo.scss"; | |
export const Foo: React.FC = () => ( | |
<div className="Foo"> | |
<Bar /> | |
</div> | |
); |
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
import React from 'react'; | |
import { hydrate } from 'react-dom'; | |
import { Foo } from './Foo'; | |
const rootElement = document.getElementById('root'); | |
hydrate(<Foo />, rootElement); |
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
module.exports = { | |
parser: 'postcss-scss', | |
plugins: [ | |
require('postcss-import')() | |
] | |
}; |
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
const MiniCssExtractPlugin = require("mini-css-extract-plugin"); | |
const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin'); | |
const safePostCssParser = require('postcss-safe-parser'); | |
module.exports = { | |
externals: { | |
react: 'React', | |
'react-dom': 'ReactDOM', | |
}, | |
entry: { | |
cssOnly: ["./cssOnlyEntry.ts"], | |
hydrated: ["./hydratedEntry.tsx"] | |
}, | |
output: { | |
path: __dirname + "/dist", | |
filename: '[name].js', | |
chunkFilename: '[name].js', | |
}, | |
resolve: { | |
modules: [ | |
'node_modules', | |
], | |
extensions: ['.ts', '.tsx'] | |
}, | |
plugins: [ | |
new MiniCssExtractPlugin() | |
], | |
module: { | |
rules: [ | |
{ | |
test: /\.tsx?$/, | |
use: ["ts-loader"] | |
}, | |
{ | |
test: /\.s?css$/, | |
use: [ | |
MiniCssExtractPlugin.loader, | |
"css-loader", | |
"postcss-loader" | |
] | |
} | |
] | |
}, | |
optimization: { | |
minimizer: [ | |
new OptimizeCSSAssetsPlugin({ | |
cssProcessorOptions: { | |
parser: safePostCssParser | |
} | |
}) | |
], | |
splitChunks: { | |
cacheGroups: { | |
default: false, | |
components: { | |
test: /(Foo|Bar)/, | |
enforce: true, | |
chunks: "initial" | |
} | |
} | |
} | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment