Initial Commit

This commit is contained in:
GiacomoHome
2021-09-17 12:41:45 +02:00
commit 9001e4656e
570 changed files with 31013 additions and 0 deletions
+132
View File
@@ -0,0 +1,132 @@
const CopyPlugin = require('copy-webpack-plugin');
// const HandlebarsPlugin = require('handlebars-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const CssMinimizerPlugin = require('css-minimizer-webpack-plugin');
const RemoveEmptyScriptsPlugin = require('webpack-remove-empty-scripts');
const TerserPlugin = require('terser-webpack-plugin');
const autoprefixer = require('autoprefixer');
const path = require('path');
const paths = {
src: {
fonts: './src/fonts',
img: './src/img',
js: './src/js',
scss: './src/scss',
},
dist: {
css: './css',
fonts: './fonts',
img: './img',
js: './js',
},
};
module.exports = {
devtool: 'source-map',
entry: {
libs: [paths.src.scss + '/libs.scss'],
theme: [paths.src.js + '/theme.js', paths.src.scss + '/theme.scss'],
},
mode: 'development',
module: {
rules: [
{
test: /\.(sass|scss)$/,
include: path.resolve(__dirname, paths.src.scss.slice(2)),
use: [
{
loader: MiniCssExtractPlugin.loader,
},
{
loader: 'css-loader',
options: {
url: false,
},
},
{
loader: 'postcss-loader',
options: {
postcssOptions: {
plugins: [['autoprefixer']],
},
},
},
{
loader: 'sass-loader',
},
],
},
],
},
optimization: {
splitChunks: {
cacheGroups: {
vendor: {
test: /[\\/](node_modules)[\\/].+\.js$/,
name: 'vendor',
chunks: 'all',
},
},
},
minimizer: [
new CssMinimizerPlugin(),
new TerserPlugin({
extractComments: false,
terserOptions: {
output: {
comments: false,
},
},
}),
],
},
output: {
filename: paths.dist.js + '/[name].bundle.js',
path: path.resolve(__dirname, 'assets'),
},
plugins: [
new CopyPlugin({
patterns: [
{
from: paths.src.fonts,
to: paths.dist.fonts,
},
{
from: paths.src.img,
to: paths.dist.img,
}
],
}),
/*new HandlebarsPlugin({
entry: path.join(process.cwd(), 'src', 'html', '**', '*.html'),
output: path.join(process.cwd(), 'dist', '[path]', '[name].html'),
partials: [path.join(process.cwd(), 'src', 'partials', '**', '*.{html,svg}')],
helpers: {
is: function (v1, v2, options) {
const variants = v2.split(' || ');
const isTrue = variants.some((variant) => v1 === variant);
return isTrue ? options.fn(this) : options.inverse(this);
},
isnt: function (v1, v2, options) {
return v1 !== v2 ? options.fn(this) : options.inverse(this);
},
webRoot: function () {
return '{{webRoot}}';
},
},
onBeforeSave: function (Handlebars, resultHtml, filename) {
const level = filename.split('//').pop().split('/').length;
const finalHtml = resultHtml.split('{{webRoot}}').join('.'.repeat(level));
return finalHtml;
},
}),*/
new RemoveEmptyScriptsPlugin(),
new MiniCssExtractPlugin({
filename: paths.dist.css + '/[name].bundle.css',
}),
],
target: 'web',
};