84 lines
2.2 KiB
JavaScript
84 lines
2.2 KiB
JavaScript
const fs = require("fs");
|
|
const path = require("path");
|
|
const webpack = require("webpack");
|
|
const HtmlWebpackPlugin = require("html-webpack-plugin");
|
|
const CleanWebpackPlugin = require("clean-webpack-plugin");
|
|
|
|
const PAGE_DIR = path.resolve(__dirname, "src", "pages");
|
|
|
|
// Collect page configurations
|
|
const page_files = fs.readdirSync(PAGE_DIR);
|
|
|
|
const pages = page_files.map(page => JSON.parse(fs.readFileSync(
|
|
path.resolve(PAGE_DIR, page),
|
|
{encoding: "UTF-8"}
|
|
)));
|
|
|
|
module.exports = {
|
|
entry: {
|
|
index: "./src/index/index.js",
|
|
mail: "./src/mail/mail.js"
|
|
},
|
|
output: {
|
|
filename: "[name].bundle.js",
|
|
path: path.resolve(__dirname, "dist")
|
|
},
|
|
plugins: [
|
|
new CleanWebpackPlugin("dist"),
|
|
new webpack.ProvidePlugin({
|
|
$: "jquery",
|
|
jQuery: "jquery"
|
|
})
|
|
].concat(pages.map(page => new HtmlWebpackPlugin(page))),
|
|
module: {
|
|
rules: [
|
|
{
|
|
test: /\.js$/,
|
|
exclude: /{node_modules}/,
|
|
use: {
|
|
loader: "babel-loader",
|
|
options: {
|
|
presets: ["babel-preset-env"]
|
|
}
|
|
}
|
|
},
|
|
{
|
|
test: /.scss$/,
|
|
use: [{
|
|
loader: "style-loader"
|
|
}, {
|
|
loader: "css-loader"
|
|
}, {
|
|
loader: "postcss-loader",
|
|
options: {
|
|
plugins: () => [
|
|
require("precss"),
|
|
require("autoprefixer")
|
|
]
|
|
}
|
|
}, {
|
|
loader: "sass-loader"
|
|
}]
|
|
},
|
|
{
|
|
test: /.html$/,
|
|
use: [{
|
|
loader: "html-loader"
|
|
}]
|
|
},
|
|
{
|
|
test: /.pug$/,
|
|
use: [{
|
|
loader: "pug-loader"
|
|
}]
|
|
},
|
|
{
|
|
test: /\.(eot|svg|ttf|woff|woff2)$/,
|
|
use: [{
|
|
loader: "file-loader"
|
|
}]
|
|
}
|
|
]
|
|
}
|
|
};
|