我可以使用postcss-import
导入Bootstrap吗?
以下是我的webpack配置的一部分:
{
test: /\.css$/,
loaders: [
{
loader: 'style-loader',
},
{
loader: 'css-loader',
options: {
importLoaders: 1,
modules: true,
localIdentName: '[folder]__[local]___[hash:base64:5]',
},
},
{
loader: 'postcss-loader',
},
],
},
我正在尝试导入使用npm安装的Bootstap:
@import 'bootstrap/dist/css/bootstrap.css';
我有一个错误:
./~/css-loader?{"importLoaders":1,"modules":true,"localIdentName":"[folder]__[local]___[hash:base64:5]"}!./~/postcss-loader/lib!./src/css/app.css
Module not found: Error: Can't resolve '../fonts/glyphicons-halflings-regular.eot' in '/home/entry/Dev/project/src/css'
@ ./~/css-loader?{"importLoaders":1,"modules":true,"localIdentName":"[folder]__[local]___[hash:base64:5]"}!./~/postcss-loader/lib!./src/css/app.css 6:4601-4653 6:4676-4728
@ ./src/css/app.css
@ ./src/js/backoffice/index.js
@ ./src/main.js
@ multi ./scripts/config/polyfills.js ./src/main.js
./~/css-loader?{"importLoaders":1,"modules":true,"localIdentName":"[folder]__[local]___[hash:base64:5]"}!./~/postcss-loader/lib!./src/css/app.css
Module not found: Error: Can't resolve '../fonts/glyphicons-halflings-regular.woff2' in '/home/entry/Dev/project/src/css'
@ ./~/css-loader?{"importLoaders":1,"modules":true,"localIdentName":"[folder]__[local]___[hash:base64:5]"}!./~/postcss-loader/lib!./src/css/app.css 6:4778-4832
@ ./src/css/app.css
@ ./src/js/backoffice/index.js
@ ./src/main.js
@ multi ./scripts/config/polyfills.js ./src/main.js
........
我还使用url-loader
作为默认加载器
{
exclude: [
/\.html$/,
/\.js$/,
/\.css$/,
/\.json$/,
],
loader: 'url-loader',
options: {
limit: 10000,
name: 'static/media/[name].[hash:8].[ext]',
},
},
我正在使用 webpack v.2.1.3, postcss-loader v.2.0.6, postcss-import v .11.0.0
答案 0 :(得分:0)
您应该将ident: 'postcss',
添加到postcss-loader
配置中,以使其有效:
{
loader: 'postcss-loader',
options: {
ident: 'postcss',
}
},
您可以阅读有关此问题的更多信息:https://github.com/facebookincubator/create-react-app/issues/2677