Angular 5错误:使用“extract-text-webpack-plugin”加载器而没有相应的插件

问题描述 投票:0回答:1

编译时我有这个错误。

./src/app/app.component.css中的错误模块构建失败:错误:使用“extract-text-webpack-plugin”加载器而没有相应的插件,请参阅https://github.com/webpack/extract-text-webp ack-plugin以获取Object.pitch的用法示例(C:\ Users \ Flamelsoft \ source \ repos \ Ecommerce \ Ecommerce \ node_m odules \ extract-text-webpack-plugin \ dist \ loader.js:57:11)

我的代码webpack.config.js是:

var webpack = require('webpack');
var path = require('path');
var HtmlWebpackPlugin = require('html-webpack-plugin');
var ExtractTextPlugin = require("extract-text-webpack-plugin");

module.exports = {
    entry: path.resolve(__dirname, 'src/main.ts'),
    devServer: {
        proxy: {
            '/api': {
                target: 'http://localhost:63995',
                secure: false
            }
        }
    },
    output: {
        path: path.resolve(__dirname, 'wwwroot'),
        filename: 'app.[hash].js'
    },
    module: {
        rules: [
            { test: /\.component.ts$/, loaders: 'angular2-template-loader' },
            { test: /\.ts$/, loaders: 'awesome-typescript-loader' },
            { test: /\.html$/, loaders: 'html-loader' },
            { test: /\.css$/, loaders: 'css-loader' },
            { test: /\.css$/, loaders: ExtractTextPlugin.extract({ fallback: "style-loader", use: "css-loader" }) }
        ]
    },
    resolve: {
        extensions: ['*', '.js', '.ts', '.html', '.css']
    },
    plugins: [
        new HtmlWebpackPlugin({
            template: './src/index.html'
        })
    ]
};

我正在使用:

 "devDependencies": {
    "@types/node": "~8.9.4",
    "angular2-template-loader": "~0.6.2",
    "awesome-typescript-loader": "~3.5.0",
    "copy-webpack-plugin": "~4.4.2",
    "css-loader": "~0.28.10",
    "extract-text-webpack-plugin": "^3.0.2",
    "file-loader": "~1.1.9",
    "html-elements-webpack-plugin": "~1.0.1",
    "html-loader": "~0.5.5",
    "html-webpack-plugin": "~2.30.1",
    "raw-loader": "~0.5.1",
    "resolve-url-loader": "~2.2.1",
    "style-loader": "~0.20.2",
    "to-string-loader": "~1.1.5",
    "ts-loader": "~3.5.0",
    "typescript": "~2.7.2",
    "url-loader": "~0.6.2",
    "webpack": "~3.11.0",
    "webpack-dev-server": "~2.11.1"
  }

任何解决方案?,我真的很感激

angular webpack css-loader extracttextwebpackplugin
1个回答
0
投票

解决方案与错误消息的说法相同:

plugins: [
        new HtmlWebpackPlugin({
            template: './src/index.html'
        }),
        new ExtractTextPlugin() // <-------------
    ]
© www.soinside.com 2019 - 2024. All rights reserved.