Answer the question
In order to leave comments, you need to log in
How to set up autoprefix in webpack?
Good evening! I want to slightly modify the existing webpack file by adding the autoprefix module to it.
I beg you to help me set up the file! Below, I will transfer my file and the code that I already found on the net that sets up the autoprefix. I just don't know how to connect them without breaking anything! Please help...
My webpack config file
const path = require('path')
const HTMLPlugin = require('html-webpack-plugin')
const MiniCssExtractPlugin = require("mini-css-extract-plugin")
const OptimizeCssAssetsPlugin = require('optimize-css-assets-webpack-plugin')
const UglifyJsPlugin = require('uglifyjs-webpack-plugin')
module.exports = {
entry: './src/index.js',
output: {
filename: 'js/bundle.js',
path: path.resolve(__dirname, 'dist')
},
optimization: {
minimizer: [
new OptimizeCssAssetsPlugin({}),
new UglifyJsPlugin({})
]
},
devServer: {
contentBase: path.resolve(__dirname, 'dist'),
port: 4200
},
plugins: [
new HTMLPlugin({
filename: 'index.html',
template: './src/index.html'
}),
new MiniCssExtractPlugin({
filename: 'css/style.css'
})
],
resolve: {
extensions: ['.js', '.ts']
},
module: {
rules: [
{
test: /\.css$/,
use: [MiniCssExtractPlugin.loader, 'css-loader']
},
{
test: /\.less$/,
use: [MiniCssExtractPlugin.loader, 'css-loader', 'less-loader']
},
{
test: /\.scss$/,
use: [MiniCssExtractPlugin.loader, 'css-loader', 'sass-loader']
},
{
test: /\.(js|ts)$/,
exclude: /node_modules/,
loader: "babel-loader"
}
]
}
}
Answer the question
In order to leave comments, you need to log in
npm i -D postcss postcss-loader autoprefixer
in rules:
{
test: /\.css$/i,
use: [
MiniCssExtractPlugin.loader,
'postcss-loader',
'css-loader'
]
}
module.exports = {
plugins: [
'autoprefixer'
]
};
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question