gpt4 book ai didi

sass - Webpack ExtractTextPlugin 在加载 Sass 时抛出错误

转载 作者:行者123 更新时间:2023-12-02 17:28:47 24 4
gpt4 key购买 nike

尝试将 sass-loader 添加到我的 webpack 配置中并遇到错误:

70% 1/1 build modules/Users/a557789/Documents/f/Portal/node_modules/webpack/node_modules/webpack-core/lib/LoadersList.js:81
r.forEach(function(r) {
^
TypeError: undefined is not a function
at /Users/a557789/Documents/f/Portal/node_modules/webpack/node_modules/webpack-core/lib/LoadersList.js:81:5
at Array.reduce (native)
at LoadersList.match (/Users/a557789/Documents/f/Portal/node_modules/webpack/node_modules/webpack-core/lib/LoadersList.js:80:27)

webpack.config:

var webpack = require("webpack");
var baseDir = "dist";

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

var path = require("path");

module.exports = {
context: __dirname + "/app",
entry: {
app: "./main"
},
resolve: {
extensions: ['', '.js', '.ts', '.css', '.scss']
},
output: {
path: __dirname + "/dist",
sourceMapFilename: "[name].map",
filename: "[name].js"
},
module: {
loaders: [
//https://www.npmjs.com/package/webpack-typescript
{
test: /\.ts$/,
loader: "ts-loader"
},
{
test: /\.scss$/,
loaders: ExtractTextPlugin.extract("style", "css!sass")
//loaders: ExtractTextPlugin.extract("style!css!sass")
}
],
noParse: [ /angular2\/bundles\/.+/ ]
},
plugins: [
new webpack.optimize.OccurenceOrderPlugin(true),
new ExtractTextPlugin("style.css"),
new HtmlWebpackPlugin({
template: "../index.html",
inject: "body"
})
],
devtool: "source-map"
};

我已经为 extract() 调用的参数尝试了一系列不同的选项,但没有成功。任何帮助将不胜感激。

最佳答案

而不是使用

loaders: ExtractTextPlugin.extract("style", "css!sass")

你应该使用

loader: ExtractTextPlugin.extract("style", "css!sass")

相反。

在这种情况下,错误不是特别具有描述性。

关于sass - Webpack ExtractTextPlugin 在加载 Sass 时抛出错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36254852/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com