postcss-loader配置好了,運行之后也沒有報錯,可是在瀏覽器中查看并沒有加上前綴,問什么?
postcss-loader配置好了,運行之后也沒有報錯,可是在瀏覽器中查看并沒有加上前綴,好疑惑??麻煩老師、大神幫忙看下,謝謝??!
以下是代碼:
var htmlWebpackPlugin=require("html-webpack-plugin");
var path=require('path');
var webpack = require('webpack');
module.exports={
???? entry:"./src/app.js",
???? output:{
???????? path:"/webpack_demo/dist",
???????? filename:"js/[name].js",
???? },
???? module:{
???????? rules:[
???????????? {
???????????????? test:/\.js$/,
???????????????? loader:'babel-loader',
???????????????? exclude:path.resolve(__dirname,'node_modules'),
???????????????? include:path.resolve(__dirname,'src/'),
???????????????? query:{
???????????????? presets:['latest']
???????????? }
???????????? },
???????????? {
???????????????? test:/.\css$/,
???????????????? loader:'style-loader!css-loader?importLoaders=1!postcss-loader'
???????????? }
????????
???????? ]
???? },
???? plugins:[
???????????? new htmlWebpackPlugin({
???????????????????? template:"index.html",
???????????????????? filename:"index.html",
???????????????????? inject:"body"
???????????? }),
???????????? new webpack.LoaderOptionsPlugin({
????????????????? ? ? options: {
???????????????????????? ? ? ? ?postcss: function() {
???????????????????????????????? ? ? ? ? ?return [
???????????????????????????????? ? ? ? ? ? ?require('autoprefixer')({
???????????????????????????????? ? ? ? ? ? ? ?broswers: ['last 5 versions']
???????????????????????????????? ? ? ? ? ? ?})
???????????????????????????????? ? ? ? ? ?]
???????????????????????? ? ? ? ?}
????????????????? ? ? }
????????????? ? })
???? ]
}
2019-09-17
2017-12-26
同問,我也碰到這個問題了
2017-09-24
{
? ?test:/\.less$/,
? ?loaders:['style-loader','css-loader',{
? ? ? ?loader:?'postcss-loader',
? ? ? ?options:?{
? ? ? ? ? ?plugins: [
? ? ? ? ? ? ? ?require('autoprefixer')({
? ? ? ? ? ? ? ? ? ?browsers:?["last?5?versions"]
? ? ? ? ? ? ? ?})
? ? ? ? ? ?]
? ? ? ?}
? ?},'less-loader']
}
我是使用這種方式能夠?qū)崿F(xiàn)(flex在common.css里邊的時候管用)
但是在使用@import引入別的css的時候importLoaders=1和后變的postcss-loader出現(xiàn)了問題。
老師上課用的webpack才1.x,先在使用的都快3.x了,所以有版本的問題。