neff-steindesign.de/themes/neff/webpack.config.js

164 lines
5.3 KiB
JavaScript

const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const CleanWebpackPlugin = require('clean-webpack-plugin');
const UglifyJsPlugin = require("uglifyjs-webpack-plugin");
const OptimizeCSSAssetsPlugin = require("optimize-css-assets-webpack-plugin");
const path = require('path');
module.exports = {
entry: {
bundle: ['./src/js/main.js'],
images: ['./src/js/images.js'],
style: ['./src/scss/main.scss'],
},
mode: 'production',
devtool: 'source-map',
context: __dirname,
output: {
filename: 'js/[name].js',
path: __dirname + '/assets',
},
module: {
rules: [
{
test: /\.m?js$/,
exclude: /node_modules/,
use: [
{
loader: 'babel-loader'
}
]
},
{
test: /\.(sa|sc|c)ss$/,
use: [
{
loader: MiniCssExtractPlugin.loader,
options: {
publicPath: '../',
sourceMap: true
}
},
{
loader: "css-loader",
options: {
sourceMap: true
}
},
{
loader: "postcss-loader",
options: {
sourceMap: true
}
},
{
loader: "sass-loader",
options: {
sourceMap: true
}
},
]
},
{
test: /\.woff2?(\?v=\d+\.\d+\.\d+)?$/,
loader: "url-loader",
options: {
limit: 1000,
mimetype: 'application/font-woff',
name: '[name].[ext]',
outputPath: '../static/fonts',
publicPath: '../fonts'
}
},
{
test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/,
loader: "url-loader",
options: {
limit: 1000,
mimetype: 'application/octet-stream',
name: '[name].[ext]',
outputPath: '../static/fonts',
publicPath: '../fonts'
}
},
{
test: /\.eot(\?v=\d+\.\d+\.\d+)?$/,
loader: "file-loader",
options: {
name: '[name].[ext]',
outputPath: '../static/fonts',
publicPath: '../fonts'
}
},
{
test: /\.svg(\?v=\d+\.\d+\.\d+)?$/,
loader: "url-loader",
options: {
limit: 1000,
mimetype: 'image/svg+xml',
name: '[name].[ext]',
outputPath: '../static/fonts',
publicPath: '../fonts'
}
},
{
test: /\/src\/img\/.*\.(ico|svg|ico|gif|jpe?g|png)$/,
use: [
{
loader: 'file-loader',
options: {
name: '../static/img/[2].[ext]',
regExp: /(src\/img)+\/(.*).(gif|svg|ico|gif|jpe?g|png)$/,
}
},
{
loader: 'image-webpack-loader',
options: {
mozjpeg: {
progressive: true,
quality: 75
},
// optipng.enabled: false will disable optipng
optipng: {
enabled: false,
},
pngquant: {
quality: '65-90',
speed: 4
},
gifsicle: {
interlaced: false,
},
}
}
]
},
]
},
plugins: [
new CleanWebpackPlugin(['assets/css/*', 'assets/js/*', 'static/fonts/*', 'static/img/*']),
new MiniCssExtractPlugin({
// Options similar to the same options in webpackOptions.output
// both options are optional
filename: "css/[name].css",
chunkFilename: "css/[id].css",
})
],
optimization: {
usedExports: true,
minimizer: [
new UglifyJsPlugin({
cache: true,
parallel: true,
sourceMap: true // set to true if you want JS source maps
}),
new OptimizeCSSAssetsPlugin({
cssProcessorOptions: {
map: {
inline: false,
annotation: true
}
}
})
]
}
};