Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MiniCSSExtract Plugin is not emitting any CSS #114

Closed
abhsrivastava opened this issue Apr 29, 2018 · 7 comments
Closed

MiniCSSExtract Plugin is not emitting any CSS #114

abhsrivastava opened this issue Apr 29, 2018 · 7 comments

Comments

@abhsrivastava
Copy link

I am using mini-css-extract-plugin version 0.4.0
node version: v9.10.1

My webpack.config looks like

const path = require('path')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
const devMode = process.env.NODE_ENV !== 'production'

module.exports = {
  entry: './src/index.tsx',
  mode: 'development',
  output: {
    path: path.resolve(__dirname, 'build'),
    filename: 'bundle.js'
  },
  module: {
    rules: [
      {
        test: /\.tsx?$/,
        loader: 'awesome-typescript-loader'
      },
      {
        enforce: 'pre',
        test: '/\.jsx?$/',
        loader: 'source-map-loader'
      },
      {
        test: /\.s?[ac]ss$/,
        use: [
          devMode ? 'style-loader' : MiniCssExtractPlugin.loader,
          'css-loader',
          'sass-loader',
        ],
      }      
    ]
  },
  plugins: [
    new HtmlWebpackPlugin({
      template: './index.html'
    }),
    new MiniCssExtractPlugin({
      filename: devMode ? '[name].css' : '[name].[hash].css',
      chunkFilename: devMode ? '[id].css' : '[id].[hash].css'
    })
  ],
  devtool: 'source-map',
  resolve: {
    extensions: ['.ts', '.tsx', '.js', '.scss']
  }
}

However when I run my project using yarn start and access it from the browser http://localhost:8080 and I go into the network tab. I don't see any CSS file. My hope was that my SCSS file will be converted into a CSS file and that CSS file will be visible in the network tab.

This is a sample project which highlights the problem.
https://github.com/abhsrivastava/login-ts-react

I also posted the problem here
https://stackoverflow.com/questions/50089859/webpack-not-creating-css-file-for-scss

@alexander-akait
Copy link
Member

@abhsrivastava Looks like a bug 👍

@arthens
Copy link

arthens commented May 13, 2018

Just ran into this problem too. As a workaround I ended up using MiniCssExtractPlugin.loader in development too (I'm not using HMR)

@alexander-akait
Copy link
Member

Yep, right now mini-css-extract-plugin are not support HMR, close in favor #34

@arthens
Copy link

arthens commented May 14, 2018

Should the docs be updated? The example provided under Advanced configuration example doesn't work without hot reloading either

@nicolauria
Copy link

This is an old post but I wanted to comment in case it helps someone. If you're using webpack-dev-server then you won't see any generated js or css file as it creates these files in memory. Try running just a normal 'webpack' command and see if the css file gets generated.

@ScriptedAlchemy
Copy link
Contributor

Use writeFilesPlugin if you want to force the in-memory output to be written to disk with Webpack-dev-server

@turbowars
Copy link

Thanks folks! I added an extra loader to my webpack config and it worked!
{
'loader' : MiniCssExtractPlugin.loader,
},

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants