Answer the question
In order to leave comments, you need to log in
Webpack SASS Autoprefixer?
Dear Webpack experts, tell me how to include autoprefixer
const webpack = require('webpack');
const path = require('path');
const UglifyJSPlugin = require('uglifyjs-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const extractSass = new ExtractTextPlugin({
filename: "./assets/css/styles.css"
});
module.exports = {
entry: {
app: './src/js/app.js',
about: './src/js/about.js',
},
output: {
path: path.resolve(__dirname, 'dist'),
filename: './assets/js/[name].js',
library: '[name]'
},
module: {
rules: [
{
test: /\.sass|scss$/,
use: ExtractTextPlugin.extract({
fallback: 'style-loader',
use: ['css-loader', 'sass-loader'],
publicPath: './dist/assets/css/'
})
},
{
test: /\.js$/,
exclude: /(node_modules|bower_components)/,
loader: 'babel-loader',
query: {
presets: ['env'],
plugins: ['transform-runtime']
}
}
]
},
devtool: "cheap-eval-source-map",
devServer: {
contentBase: path.join(__dirname, 'dist'),
compress: true,
port: 9000,
stats: 'errors-only',
open: true
},
plugins: [
extractSass,
new HtmlWebpackPlugin({
title: 'My App',
filename: 'index.html',
template: './src/index.html',
hash: true,
// minify: { collapseWhitespace: true },
chunks: ['app', 'common']
}),
new HtmlWebpackPlugin({
title: 'About',
filename: 'about.html',
template: './src/about.html',
hash: true,
// minify: { collapseWhitespace: true },
chunks: ['about', 'common']
}),
new ExtractTextPlugin("./assets/css/styles.css"),
new webpack.optimize.CommonsChunkPlugin({
name: 'common',
chunks: ['about', 'app']
}),
// new UglifyJSPlugin(),
]
}
module.exports = {
plugins: [
require('autoprefixer')
]
}
use: ['css-loader', 'postcss-loader', 'sass-loader'],
"browserslist": [
"> 1%",
"last 2 versions"
]
Answer the question
In order to leave comments, you need to log in
For my (and not so) Django/Flask projects, I use this set of configs:
https://gist.github.com/koddr/3d8be47815dce570fcf2...
Includes: Autoprefixer, PostCSS, SCSS, Vue.js and Babel . Configs are tested and used in production, like a skeleton, to quickly deploy the environment.
module: {
rules: [
{
test: /\.sass|scss$/,
use: ExtractTextPlugin.extract({
fallback: 'style-loader',
use: ['css-loader', 'sass-loader'],
publicPath : './dist/assets/css/'
})
},
{
test: /\.css/,
loader: 'css!style!autoprefixer!?browsers=last 12 versions',
},
{
test: /\.js $/,
exclude: /(node_modules|bower_components)/,
loader: 'babel-loader',
query: {
presets: ['env'],
plugins: ['transform-runtime']
}
}
]
docs for this
https://github.com/passy/autoprefixer-loader
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question