1:⚠️⚠️ 首先安裝依賴 npm install --save-dev webpack style-loader css-loader postcss-loader sass-loader autoprefixercss
2:而後配置webpackwebpack
module: { rules: [ web
{ test: /\.css$/, use: ['style-loader', 'css-loader'] },npm
{ test: /\.scss$/, use: [ json
{ loader: 'style-loader' }, 瀏覽器
{ loader: 'css-loader', options: { sourceMap: true, modules: true, localIdentName: '[local]_[hash:base64:5]' } }, sass
{ loader: 'postcss-loader', options: { sourceMap: true, config: { path: 'postcss.config.js' // 這個得在項目根目錄建立此文件 } } }, post
//{loader: 'sass-loader', options: { sourceMap: true } }ui
] spa
}
]
},
module.exports = { plugins: [ require('autoprefixer') ] };
"browserslist": [ "defaults", "not ie < 11", "last 2 versions", "> 1%", "iOS 6", "last 3 iOS versions" ];
待webpack打包以後會自動加上瀏覽器前綴