hugo-theme-hello-friend/webpack.config.js

109 lines
2.5 KiB
JavaScript
Raw Normal View History

const Webpack = require("webpack");
const ExtractTextPlugin = require("extract-text-webpack-plugin");
const CleanPlugin = require("clean-webpack-plugin");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const UglifyJsPlugin = require("uglifyjs-webpack-plugin");
2018-07-20 19:14:22 +02:00
const path = require("path");
2018-07-20 19:14:22 +02:00
const join = (...paths) => path.join(__dirname, ...paths);
2018-07-20 19:14:22 +02:00
module.exports = {
resolve: {
extensions: [".js", ".css"],
modules: ["source", "node_modules"],
2018-07-20 19:14:22 +02:00
},
entry: {
"main.js": [
join("source", "js", "index.js"),
join("source", "js", "menu.js"),
join("source", "js", "theme.js"),
],
"prism.js": join("source", "js", "prism.js"),
"style.css": join("source", "css", "style.css"),
2018-07-20 19:14:22 +02:00
},
output: {
filename: "[name]",
path: join("static/assets"),
publicPath: "",
2018-07-20 19:14:22 +02:00
},
performance: {
hints: false,
2018-07-20 19:14:22 +02:00
},
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: {
loader: "babel-loader",
2018-07-20 19:14:22 +02:00
options: {
presets: ["@babel/preset-env"],
},
},
2018-07-20 19:14:22 +02:00
},
{
test: /\.(png|jpg|woff|woff2|ttf|eot|svg)$/,
use: [
{
loader: "url-loader",
2018-07-20 19:14:22 +02:00
options: {
limit: 8192,
},
},
],
2018-07-20 19:14:22 +02:00
},
{
test: /\.css$/,
use: ExtractTextPlugin.extract({
fallback: "style-loader",
2018-07-20 19:14:22 +02:00
use: [
{
loader: "css-loader",
2018-07-20 19:14:22 +02:00
options: {
minimize: true,
modules: true,
importLoaders: 1,
localIdentName: "[local]",
},
2018-07-20 19:14:22 +02:00
},
{
loader: "postcss-loader",
2018-07-20 19:14:22 +02:00
options: {
config: {
path: "postcss.config.js",
},
},
},
],
}),
},
],
2018-07-20 19:14:22 +02:00
},
optimization: {
splitChunks: {
name: "vendor",
minChunks: 2,
2018-07-20 19:14:22 +02:00
},
minimizer: [
new UglifyJsPlugin({
sourceMap: false,
}),
],
2018-07-20 19:14:22 +02:00
},
plugins: [
new CleanPlugin(join("static/assets")),
2018-07-20 19:14:22 +02:00
new HtmlWebpackPlugin({
template: join("source", "html", "inject.script.ejs"),
filename: join("layouts", "partials", "inject.script.html"),
inject: false,
2018-07-20 19:14:22 +02:00
}),
new HtmlWebpackPlugin({
template: join("source", "html", "inject.stylesheet.ejs"),
filename: join("layouts", "partials", "inject.stylesheet.html"),
2018-07-20 19:14:22 +02:00
inject: false,
}),
new ExtractTextPlugin("[name]"),
],
};