webpack error: File to import not found or unreadable: bourbon , how to fix?
webpack error: File to import not found or unreadable: bourbon , how to fix?
我正在尝试将 Bourbon 包加载到我的 SCSS 文件中。我正在使用 Angular 2,这是我的 webpack 3.0 配置:
var path = require("path");
var webpack = require("webpack");
module.exports = {
devServer: {
contentBase: path.join(__dirname, "build"),
compress: true,
port: 9000
},
node: {
fs: 'empty'
},
cache: true,
devtool: "eval", //or cheap-module-eval-source-map
entry: {
app: path.join(__dirname, "client/app", "app.js")
},
output: {
path: path.join(__dirname, "buildf"),
filename: "ha.js",
chunkFilename: "[name].js"
},
plugins: [
//Typically you'd have plenty of other plugins here as well
new webpack.DllReferencePlugin({
context: path.join(__dirname, "client"),
manifest: require("./build/vendor-manifest.json")
}),
],
module: {
loaders: [
{
test: /\.js?$/,
loader: "babel-loader",
include: [
path.join(__dirname, "client") //important for performance!
],
exclude: [
path.join(__dirname, "node_modules")
],
query: {
cacheDirectory: true, //important for performance
plugins: ["transform-regenerator"],
presets: ["es2015", "stage-0"]
}
},
{ test: /\.(scss|sass)$/, loader: ['style-loader', 'css-loader', 'sass-loader'] },
{ test: /\.html$/, loader: 'raw-loader' },
{ test: /\.css$/, loader: 'css-loader' }
]
}
};
当我 运行 webpack 我得到这个错误:
ERROR in
./node_modules/css-loader!./node_modules/sass-loader!./client/app/app.scss
Module build failed: @import "bourbon"; ^
File to import not found or unreadable: bourbon. Parent style sheet: stdin
in /Users/john/NG6-starter/client/app/app.scss (line 2, column 1) @ ./client/app/app.scss 4:14-116 @ ./client/app/app.component.js
@ ./client/app/app.js @ multi
(webpack)-dev-server/client?http://localhost:9000 ./client/app/app.js
webpack: Failed to compile.
为什么找不到bourbon组件?这是 link 到 code
module: {
rules: [{
test: /\.scss$/,
use: [{
loader: "style-loader"
}, {
loader: "css-loader"
}, {
loader: "sass-loader",
options: {
sassOptions: {
includePaths: ["node_modules/bourbon/core"],
}
}
}]
}]
}
8.0.0 之前的版本:
您需要将 options.includePaths
传递给 sass-loader
:
module: {
rules: [{
test: /\.scss$/,
use: [{
loader: "style-loader"
}, {
loader: "css-loader"
}, {
loader: "sass-loader",
options: {
includePaths: ["node_modules/bourbon/core"]
}
}]
}]
}
我正在尝试将 Bourbon 包加载到我的 SCSS 文件中。我正在使用 Angular 2,这是我的 webpack 3.0 配置:
var path = require("path");
var webpack = require("webpack");
module.exports = {
devServer: {
contentBase: path.join(__dirname, "build"),
compress: true,
port: 9000
},
node: {
fs: 'empty'
},
cache: true,
devtool: "eval", //or cheap-module-eval-source-map
entry: {
app: path.join(__dirname, "client/app", "app.js")
},
output: {
path: path.join(__dirname, "buildf"),
filename: "ha.js",
chunkFilename: "[name].js"
},
plugins: [
//Typically you'd have plenty of other plugins here as well
new webpack.DllReferencePlugin({
context: path.join(__dirname, "client"),
manifest: require("./build/vendor-manifest.json")
}),
],
module: {
loaders: [
{
test: /\.js?$/,
loader: "babel-loader",
include: [
path.join(__dirname, "client") //important for performance!
],
exclude: [
path.join(__dirname, "node_modules")
],
query: {
cacheDirectory: true, //important for performance
plugins: ["transform-regenerator"],
presets: ["es2015", "stage-0"]
}
},
{ test: /\.(scss|sass)$/, loader: ['style-loader', 'css-loader', 'sass-loader'] },
{ test: /\.html$/, loader: 'raw-loader' },
{ test: /\.css$/, loader: 'css-loader' }
]
}
};
当我 运行 webpack 我得到这个错误:
ERROR in ./node_modules/css-loader!./node_modules/sass-loader!./client/app/app.scss Module build failed: @import "bourbon"; ^ File to import not found or unreadable: bourbon. Parent style sheet: stdin in /Users/john/NG6-starter/client/app/app.scss (line 2, column 1) @ ./client/app/app.scss 4:14-116 @ ./client/app/app.component.js @ ./client/app/app.js @ multi (webpack)-dev-server/client?http://localhost:9000 ./client/app/app.js webpack: Failed to compile.
为什么找不到bourbon组件?这是 link 到 code
module: {
rules: [{
test: /\.scss$/,
use: [{
loader: "style-loader"
}, {
loader: "css-loader"
}, {
loader: "sass-loader",
options: {
sassOptions: {
includePaths: ["node_modules/bourbon/core"],
}
}
}]
}]
}
8.0.0 之前的版本:
您需要将 options.includePaths
传递给 sass-loader
:
module: {
rules: [{
test: /\.scss$/,
use: [{
loader: "style-loader"
}, {
loader: "css-loader"
}, {
loader: "sass-loader",
options: {
includePaths: ["node_modules/bourbon/core"]
}
}]
}]
}