hugo-theme-terminal/webpack.config.js

112 lines
2.7 KiB
JavaScript
Raw Normal View History

2019-01-28 03:11:02 +03:00
const Webpack = require("webpack");
2020-09-06 01:31:08 +03:00
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const { CleanWebpackPlugin } = require("clean-webpack-plugin");
2019-01-28 03:11:02 +03:00
const HtmlWebpackPlugin = require("html-webpack-plugin");
const UglifyJsPlugin = require("uglifyjs-webpack-plugin");
const path = require("path");
const join = (...paths) => path.join(__dirname, ...paths);
2020-09-06 01:31:08 +03:00
module.exports = (env, { mode }) => ({
2019-01-28 03:11:02 +03:00
resolve: {
extensions: [".js", ".css"],
2020-09-06 01:31:08 +03:00
modules: ["assets", "node_modules"],
2019-01-28 03:11:02 +03:00
},
entry: {
main: join("assets", "js", "menu.js"),
languageSelector: join("assets", "js", "languageSelector.js"),
2020-09-06 01:31:08 +03:00
prism: join("assets", "js", "prism.js"),
style: join("assets", "css", "style.css"),
red: join("assets", "css", "color", "red.css"),
blue: join("assets", "css", "color", "blue.css"),
green: join("assets", "css", "color", "green.css"),
pink: join("assets", "css", "color", "pink.css"),
2019-01-28 03:11:02 +03:00
},
output: {
2020-09-06 01:31:08 +03:00
filename: "[name].js",
2019-01-28 03:11:02 +03:00
path: join("static/assets"),
publicPath: "",
},
performance: {
hints: false,
},
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: {
loader: "babel-loader",
options: {
presets: ["@babel/preset-env"],
},
},
},
{
test: /\.(png|jpg|woff|woff2|ttf|eot|svg)$/,
use: [
{
loader: "url-loader",
options: {
limit: 8192,
},
},
],
},
{
test: /\.css$/,
2020-09-06 01:31:08 +03:00
use: [
MiniCssExtractPlugin.loader,
{
loader: "css-loader",
options: {
modules: {
2019-01-28 03:11:02 +03:00
localIdentName: "[local]",
},
2020-09-06 01:31:08 +03:00
import: true,
importLoaders: 1,
2019-01-28 03:11:02 +03:00
},
2020-09-06 01:31:08 +03:00
},
{
loader: "postcss-loader",
options: {
config: {
path: "postcss.config.js",
2019-01-28 03:11:02 +03:00
},
},
2020-09-06 01:31:08 +03:00
},
],
2019-01-28 03:11:02 +03:00
},
],
},
optimization: {
splitChunks: {
name: "vendor",
minChunks: 2,
},
minimizer: [
new UglifyJsPlugin({
2019-02-01 12:15:28 +03:00
sourceMap: true,
2019-01-28 03:11:02 +03:00
}),
],
},
2020-09-06 01:31:08 +03:00
plugins: [
new CleanWebpackPlugin({
cleanOnceBeforeBuildPatterns: [join("static/assets")],
cleanAfterEveryBuildPatterns: [
join("static/assets/style.js"),
join("static/assets/blue.js"),
join("static/assets/green.js"),
join("static/assets/red.js"),
join("static/assets/pink.js"),
],
verbose: true,
}),
new MiniCssExtractPlugin({
filename: "[name].css",
chunkFilename: "[id].css",
}),
],
});