webpack-contrib / extract-text-webpack-plugin

[DEPRECATED] Please use https://github.com/webpack-contrib/mini-css-extract-plugin Extracts text from a bundle into a separate file
MIT License
4.01k stars 513 forks source link

Can someone tell me what is wrong here? #314

Closed jesperlandberg closed 7 years ago

jesperlandberg commented 7 years ago

I'm trying to extract my css but get lots of errors. Using "extract-text-webpack-plugin": "2.0.0-beta.4" and "webpack": "2.1.0-beta.25".

This is my setup:

'use strict';

const webpack = require("webpack");
const ExtractTextPlugin = require("extract-text-webpack-plugin");

module.exports = {
    context: __dirname + "/src",
    entry: {
        app: "./js/app.js",
    },
    output: {
        path: __dirname + "/dist",
    publicPath: "/dist/",
        filename: "[name].bundle.js",
    },
  devServer: {
    contentBase: __dirname + "/src",
  },
    module: {
    loaders: [
      {
        test: /\.js$/,
        exclude: /node_modules/,
        use: [{
          loader: "babel-loader",
          options: { presets: ["es2015"] }
        }],
      },
            {
        test: /\.(sass|scss)$/,
        loader: ExtractTextPlugin.extract(["style-loader", "css-loader?importLoaders=1", "postcss-loader", "sass-loader"])
      },
      { 
        test: /\.(png|woff|woff2|eot|ttf|svg)$/, 
        loader: 'url-loader?limit=100000' 
      }
    ],
  },
  externals: {
      'TweenLite': 'TweenLite'
  },
  plugins: [
    new webpack.LoaderOptionsPlugin({
      options: {
        postcss: [
          require ('postcss-cssnext'),
        ],
      },
    }),
    new ExtractTextPlugin("app.bundle.css")
  ],
};
TuiKiken commented 7 years ago

I think you should remove style-loader from ExtractTextPlugin.extract()

bebraw commented 7 years ago

ExtractTextPlugin.extract signature is a little different now. Please see the readme for a good example.