I have a Webpack + Angular project and I want to have a separate global stylesheet alongside the component styles, similar to what angular-cli does out of the box. I am using sass for the component styles, and want to have a global tailwind built stylesheet. I want the global styles module extracted into the head with something like MiniCssExtractPlugin. The issue is that I am getting a "ERROR in window is not defined" when trying to do this. Here is my webpack style config, which loads component styles as expected:
{
test: /\.(scss|css)$/,
use: [
'to-string-loader', // Return component styles as strings
{
loader: 'css-loader', // Translates CSS into CommonJS
options: {
sourceMap: true
}
},
{
loader: 'sass-loader', // Compiles Sass to CSS, using Node Sass by default
options: {
sourceMap: true
}
},
]
}
To add a global tailwind module, I added another webpack entry pointing to the sass file:
entry: {
app: './src/main',
styles: './src/assets/styles/styles'
}
and the postcss loader like so:
{
test: /\.(scss|css)$/,
use: [
'to-string-loader', // Return component styles as strings
{
loader: 'style-loader',
options: {
sourceMap: false
}
},
{
loader: 'css-loader', // Translates CSS into CommonJS
options: {
sourceMap: true
}
},
{
loader: 'postcss-loader', // Process tailwindcss,
options: {
plugins: [
tailwindcss('./tailwind.js'),
require('autoprefixer'),
],
}
},
{
loader: 'sass-loader', // Compiles Sass to CSS, using Node Sass by default
options: {
sourceMap: true
}
},
]
}
I am getting "ERROR in window is not defined" when building the project. What is wrong with my config?