为什么 css-loader/style-loader 会抛出意外字符 # 错误?

Why css-loader/style-loader throws unexpected character # error?

我接受了Webpack tutorial from Angular.io and started to upgrade to Webpack 2 following the official and a not official指南。

我遇到了以下错误:

ERROR in ./public/css/styles.css Module parse failed: DashboardDelivery.Host.Ui.Spa\public\css\styles.css Unexpected character '#' (3:16) You may need an appropriate loader to handle this file type. | body | { | background: #0147A7; | color: #fff; | }

基本上,无论我做什么,总是有问题,而且与角色有关的是最奇怪的。我在这里缺少什么?

webpack.common.js

var webpack = require('webpack');
var HtmlWebpackPlugin = require('html-webpack-plugin');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var helpers = require('./helpers');

module.exports = {
    entry: {
        'polyfills': './src/app/polyfills.ts',
        'vendor': './src/app/vendor.ts',
        'app': './src/app/main.ts'
    },

    resolve: {
        extensions: ['.ts', '.js']
    },

    module: {
        rules: [
          {
              test: /\.ts$/,
              use: ['awesome-typescript-loader', 'angular2-template-loader']
          },
          {
              test: /\.html$/,
              use: 'html-loader'
          },
          {
              test: /\.(png|jpe?g|gif|svg|woff|woff2|ttf|eot|ico)$/,
              use: 'file-loader?name=assets/[name].[hash].[ext]'
          },
          {
              test: /\.css$/,
              exclude: helpers.root('src', 'app'),
              use: ExtractTextPlugin.extract(
                  {
                      fallbackLoader: 'style-loader',
                      loader: 'css-loader?sourceMap',
                      publicPath: "/dist"
                  })
          },
          {
              test: /\.css$/,
              include: helpers.root('src', 'app'),
              use: 'raw-loader'
          }
        ]
    },

    plugins: [
      new webpack.optimize.CommonsChunkPlugin({
          name: ['app', 'vendor', 'polyfills']
      }),

      new HtmlWebpackPlugin({
          template: 'src/index.html'
      }),

    ]
};

webpack.dev.js

var webpackMerge = require('webpack-merge');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var commonConfig = require('./webpack.common.js');
var helpers = require('./helpers');

module.exports = webpackMerge(commonConfig, {
    devtool: 'cheap-module-eval-source-map',

    output: {
        path: helpers.root('dist'),
        publicPath: 'http://localhost:8080/',
        filename: '[name].js',
        chunkFilename: '[id].chunk.js'
    },

    plugins: [
      new ExtractTextPlugin('[name].css')
    ],

    devServer: {
        historyApiFallback: true,
        stats: 'minimal'
    }
});

style.css

body 
{
    background: #0147A7;
    color: #fff;
}

经过几个小时的努力寻找答案,找到了答案...ExtractTextPlugin 不适用于新的使用语法。这里是 blog I found the suggestion, and here is the bug ticket.