File: //proc/693/cwd/frontend/webpack.common.js
const path = require("path");
//OLD//const MiniCssExtractPlugin = require("extract-css-chunks-webpack-plugin");
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const CopyWebpackPlugin = require("copy-webpack-plugin");
const StyleLintPlugin = require('stylelint-webpack-plugin');
// // Testing feature at 2021.03.24
// const { CleanWebpackPlugin } = require('clean-webpack-plugin')
// Webpack 5
// const TerserPlugin = require('terser-webpack-plugin');
// const PurgecssPlugin = require('purgecss-webpack-plugin')
// const glob = require('glob')
// const PATHS = {
// src: path.join(__dirname, 'src')
// }
module.exports = {
entry: {
app: "./index.js",
},
output: {
filename: "[name].bundle.js",
// chunkFilename: "[name].bundle.js",
path: path.resolve(__dirname, "build/")
},
//devtool: "source-map",
plugins: [
// new StyleLintPlugin({
// configFile: ".stylelintrc",
// context: "src",
// files: ["**/*.css"]
// }),
// new PurgecssPlugin({
// paths: glob.sync(`${PATHS.src}/**/*`, {
// nodir: true
// }),
// }),
//new CleanWebpackPlugin(),
new CopyWebpackPlugin({
patterns: [
// {
// /* Bootstrap 5 SCSS get last build */
// from: "node_modules/bootstrap/scss",
// to: "../src/bootstrap/scss",
// toType: "dir",
// force: true
// },
// {
// /* Bootstrap 5 JS get last build */
// from: "node_modules/bootstrap/js",
// to: "../src/bootstrap/js",
// toType: "dir",
// force: true
// },
// {
// /* Build styles */
// from: "build",
// to: "../../static_files/build_new",
// toType: "dir",
// force: true
// },
// {
// /* React project builder */
// from: "build",
// to: "../static/build",
// toType: "dir",
// force: true
// }
// {
// // Build the full-weight version
// from: "build",
// to: "../../static/build",
// toType: "dir",
// force: true
// },
{
// Build the minified version
from: "build",
to: "../../static_files/build",
toType: "dir",
force: true
},
// {
// // Make FontAwesome fonts build
// //from: "fonts/fontawesome/",
// from: "node_modules/@fortawesome/fontawesome-free",
// to: "../../static/fonts/fontawesome",
// toType: "dir",
// force: true
// },
// {
// // Make FontAwesome fonts build
// //from: "fonts/fontawesome/",
// from: "node_modules/@fortawesome/fontawesome-free",
// to: "../../static_files/fonts/fontawesome",
// toType: "dir",
// force: true
// },
{
from: "node_modules/@fortawesome/fontawesome-free/svgs",
to: "../../static_files/fonts/fontawesome/svgs",
toType: "dir",
force: true
},
{
from: "node_modules/@fortawesome/fontawesome-free/webfonts",
to: "../../static_files/fonts/fontawesome/webfonts",
toType: "dir",
force: true
},
// Fonts
{
from: "fonts-package/",
to: "../../static_files/fonts/",
toType: "dir",
force: true
},
// {
// from: "fonts-package/roboto-condensed/",
// to: "../../static_files/fonts/roboto-condensed/",
// toType: "dir",
// force: true
// },
// {
// from: "fonts-package/russo-one/",
// to: "../../static_files/fonts/russo-one/",
// toType: "dir",
// force: true
// },
// {
// from: "fonts-package/fonts.css",
// to: "../../static_files/fonts/fonts.css",
// toType: "file",
// force: true
// },
],
options: {
concurrency: 100
}
}),
// Webpack 5
// new TerserPlugin({
// parallel: true,
// terserOptions: {
// ecma: 6,
// },
// }),
],
resolve: {
extensions: [".js", ".jsx"]
},
module: {
rules: [
{
test: /\.(?:ico|gif|png|jpg|jpeg)$/i,
type: 'asset/resource',
},
{
test: /\.(woff(2)?|eot|ttf|otf|svg|)$/,
type: 'asset/inline',
},
{
// eslint-disable-next-line require-unicode-regexp
test: /\.(js|jsx)$/,
// eslint-disable-next-line require-unicode-regexp
exclude: /node_modules/,
use: {
loader: "babel-loader",
options: {
presets: [
/* 'env',
'es2015'*/
/*'@babel/react',*/
"@babel/env"
]
}
}
},
/* {
test: /\.html$/,
use: [
{
loader: "html-loader",
options: {
minimize: true
}
}
]
},*/
/* {
test: /\.css$/,
use: [
MiniCssExtractPlugin.loader,
"css-loader",
//'style-loader',
//{
// loader: 'css-loader',
// options: { importLoaders: 1 }
//},
//'postcss-loader'
]
},*/
/* {
test: /\.css$/,
use: [
{
loader: 'style-loader'
},
{
loader: 'css-loader'
}
]
},*/
// {
// test: /\.css$/i,
// use: [
// MiniCssExtractPlugin.loader,
// "style-loader",
// "css-loader"
// ]
// },
{
// eslint-disable-next-line require-unicode-regexp
test: /\.(scss|css)$/i,
use: [
MiniCssExtractPlugin.loader,
//
// /* {
// loader: "css-loader",
// options: {
// modules: true,
// sourceMap: true,
// importLoader: 2
// }
// },*/
// {
// // inject CSS to page
// loader: 'style-loader'
// },
{
// translates CSS into CommonJS modules
loader: 'css-loader'
},
{
// Run postcss actions
loader: 'postcss-loader',
options: {
// `postcssOptions` is needed for postcss 8.x;
// if you use postcss 7.x skip the key
postcssOptions: {
// postcss plugins, can be exported to postcss.config.js
plugins: function () {
return [
require('autoprefixer')
];
}
}
}
},
{
// compiles Sass to CSS
loader: 'sass-loader'
}
]
//
// /* for Webpack <4
// use: extractSass.extract({
// use: [{
// loader: "css-loader",
// options: {
// minimize: true
// }
// },{
// loader: "sass-loader",
// options: {
// minimize:true
// }
// }]
// })*/
},
// {
// test: /\.(eot|svg|ttf|woff|woff2)$/,
// loader: 'file?name=public/fonts/[name].[ext]',
// //options: {
// // name: '[name].[ext]',
// // outputPath: 'fonts/'
// //}
// },
// Commented at 2021.03.24
// {
// // eslint-disable-next-line require-unicode-regexp
// test: /.(ttf|otf|eot|svg|woff(2)?)(\?[a-z0-9]+)?$/,
// use: [
// {
// loader: "file-loader",
// options: {
// name: "[name].[ext]",
// outputPath: "../../static_files/fonts/", // where the fonts will go
// publicPath: "/static/fonts/" // override the default path
// }
// },
// // {
// // loader: "file-loader",
// // options: {
// // name: "[name].[ext]",
// // outputPath: "../../static_files/fonts/roboto/", // where the fonts will go
// // publicPath: "/static/fonts/roboto/" // override the default path
// // }
// // },
// // {
// // loader: "file-loader",
// // options: {
// // name: "[name].[ext]",
// // outputPath: "../../static_files/fonts/roboto-condensed/", // where the fonts will go
// // publicPath: "/static/fonts/roboto-condensed/" // override the default path
// // }
// // }
// ]
// },
// {
// // eslint-disable-next-line require-unicode-regexp
// test: /\.(gif|png|jpe?g)$/i,
// use: [{
// loader: "file-loader",
// options: {
// name: "[name].[ext]",
// outputPath: "assets/webpack/images/", // where the fonts will go
// publicPath: "/dist/" // override the default path
// }
// }]
// }
/* {
test: /\.svg$/,
loader: 'svg-inline'
},*/
/* {
test: /jquery\.js$/,
loader: 'expose?$'
},*/
/* {
test: /jquery\.js$/,
loader: 'expose?jQuery'
}*/
]
}
};