webpack5下请求浏览器前缀问题
来源:3-3 使用 Loader 打包静态资源(样式篇 - 上)
qq_京门_03145109
2021-07-07
一开始的时候用的是autoprefixer,无效,后来换成postcss-preset-env还是无效。重点是还不报错,看了文档,还是没有找到解决方案,烦请老师解惑。
node版本:v13.14.0
npm版本:6.14.4
webpack.config.js
const path = require('path')
module.exports = {
mode: 'development',
entry: {
main: './src/index.js'
},
module: {
rules: [{
test: /\.(jpg|png|gif)$/,
use: {
loader: 'url-loader',
options: {
name: '[name]_[hash].[ext]',
outputPath: 'images/',
limit: 2048
}
}
}, {
test: /\.less$/,
use: [
'style-loader',
'css-loader',
'less-loader',
{
loader: "postcss-loader",
options: {
postcssOptions: {
plugins: [
['postcss-preset-env']
]
}
}
}
]
}]
},
//出口配置
output: {
filename: 'bundle.js',
//__dirname 当前文件所在的绝对路径
path: path.resolve(__dirname, 'dist')
}
}
package.json
{
"name": "webpack5",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"build": "webpack"
},
"author": "",
"license": "ISC",
"devDependencies": {
"css-loader": "^5.2.6",
"file-loader": "^6.2.0",
"less": "^4.1.1",
"less-loader": "^10.0.1",
"postcss": "^8.3.5",
"postcss-loader": "^6.1.1",
"postcss-preset-env": "^6.7.0",
"style-loader": "^2.0.0",
"url-loader": "^4.1.1",
"webpack": "^5.43.0",
"webpack-cli": "^4.7.2"
},
"dependencies": {},
"browserslist": [
"> 1%",
"last 2 versions",
"not ie <= 8"
]
}
写回答
1回答
-
qq_京门_03145109
提问者
2021-07-07
已解决
022022-03-11
相似问题