varbase_layout_builder-9.0.0-alpha2/webpack.config.js
webpack.config.js
const path = require('path');
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const SVGSpritemapPlugin = require('svg-spritemap-webpack-plugin');
const autoprefixer = require('autoprefixer');
const RemoveEmptyScriptsPlugin = require('webpack-remove-empty-scripts');
const isDev = (process.env.NODE_ENV !== 'production');
// Compiling SCSS files for Varbase Layout Builder styling enhancements.
module.exports = {
mode: 'production',
entry: {
// ################################################
// SCSS
// ################################################
// Theme
'vlb-enhancements.base': ['./scss/theme/vlb-enhancements.base.scss'],
'layout-builder-ux': ['./scss/theme/layout-builder-ux.scss'],
'vlb-tabs-group.theme': ['./scss/theme/vlb-tabs-group.theme.scss']
},
output: {
path: path.resolve(__dirname, 'css/theme'),
pathinfo: false,
publicPath: '',
},
module: {
rules: [
{
test: /\.(png|jpe?g|gif|svg)$/,
exclude: /sprite\.svg$/,
type: 'javascript/auto',
use: [{
loader: 'file-loader',
options: {
name: '[path][name].[ext]', //?[contenthash]
outputPath: '../../',
esModule: false,
},
},
{
loader: 'img-loader',
options: {
enabled: !isDev,
},
},
],
},
{
test: /\.(css|scss)$/,
use: [
{
loader: MiniCssExtractPlugin.loader,
},
{
loader: 'css-loader',
options: {
sourceMap: isDev,
importLoaders: 2,
url: {
filter: (url) => {
// Don't handle sprite svg or any image paths
if (url.includes('sprite.svg') || url.includes('/images/')) {
return false;
}
return true;
}
},
},
},
{
loader: 'postcss-loader',
options: {
sourceMap: isDev,
postcssOptions: {
plugins: [
autoprefixer()
],
},
},
},
{
loader: 'sass-loader',
options: {
sourceMap: isDev,
// Global SCSS imports:
additionalData: `
@use "sass:color";
@use "sass:math";
`,
},
},
],
},
],
},
resolve: {
modules: [
path.join(__dirname, 'node_modules'),
],
extensions: ['.js', '.json'],
},
plugins: [
new RemoveEmptyScriptsPlugin(),
new CleanWebpackPlugin({
cleanStaleWebpackAssets: false
}),
new MiniCssExtractPlugin(),
],
watchOptions: {
aggregateTimeout: 300,
ignored: ['**/*.woff', '**/*.json', '**/*.woff2', '**/*.jpg', '**/*.png', '**/*.svg', 'node_modules', 'images'],
}
};
