我在使用webpacker的rails5应用程序上使用Bulma CSS Framework。
当我将css文件构建为./bin/webpack-dev-server
时,我收到如下警告。有谁知道消除它们?
23:37:47 webpacker.1 | WARNING in ./node_modules/css-loader?{"minimize":false}!./node_modules/postcss-loader/lib?{"sourceMap":true}!./node_modules/resolve-url-loader!./node_modules/sass-loader/lib/loader.js?{"sourceMap":true}!./node_modules/import-glob-loader!./app/javascript/stylesheets/application.scss
23:37:47 webpacker.1 | (Emitted value instead of an instance of Error) postcss-custom-properties: /some_rails_app/app/javascript/stylesheets/application.scss:9284:3: Custom property ignored: not scoped to the top-level :root element (.columns.is-variable { ... --columnGap: ... })
答案 0 :(得分:1)
我在github上发现了这个问题https://github.com/MoOx/postcss-cssnext/issues/186,以及我如何设置摆脱警告。
<强>终端强>
yarn add postcss-cssnext
在 config / webpack / loaders / sass.js
中为postcss-loader添加新选项{
loader: 'postcss-loader',
options: {
sourceMap: true,
plugins: (loader) => [
require('postcss-cssnext')({
features: {
customProperties: {
warnings: false
}
}
})
]
}
},
或者,如果你没有使用postcss,只需删除postcss-loader,你就可以了。
答案 1 :(得分:1)
我在React和webpack配置方面遇到了类似的问题。所以我添加了postcss.config.js
文件并添加了以下代码:
const postcssCssNext = require('postcss-cssnext')
const postcssImport = require('postcss-import')
module.exports = {
plugins: [
postcssCssNext({
features: {
customProperties: {
warnings: false
}
}
}),
postcssImport
]
}