57 lines
1.7 KiB
JavaScript
57 lines
1.7 KiB
JavaScript
const webpack = require("webpack");
|
|
const { BannerPlugin } = require("webpack");
|
|
const HtmlWebpackPlugin = require("html-webpack-plugin");
|
|
const path = require("path");
|
|
const CopyWebpackPlugin = require("copy-webpack-plugin");
|
|
const CleanWebpackPlugin = require("clean-webpack-plugin");
|
|
const ExtractTextPlugin = require("extract-text-webpack-plugin");
|
|
const packageJson = require("../package.json"); // Load package.json
|
|
const commitHash = require("child_process")
|
|
.execSync("git rev-parse --short HEAD")
|
|
.toString()
|
|
.trim();
|
|
|
|
module.exports = {
|
|
context: path.resolve(__dirname, "../"),
|
|
entry: {
|
|
webssh2: "./client/src/js/index.js",
|
|
},
|
|
plugins: [
|
|
new BannerPlugin({
|
|
banner: `Version ${packageJson.version} - ${new Date().toISOString()}`,
|
|
include: /\.(js|css|html|htm)$/,
|
|
}),
|
|
new CleanWebpackPlugin(["client/public"], {
|
|
root: path.resolve("__dirname", "../"),
|
|
verbose: true,
|
|
}),
|
|
new HtmlWebpackPlugin({
|
|
template: "./client/src/client.htm", // Path to your source template
|
|
filename: "client.htm", // Optional: output file name, defaults to index.html
|
|
minify: false,
|
|
scriptLoading: "blocking",
|
|
version: `Version ${
|
|
packageJson.version
|
|
} - ${new Date().toISOString()} - ${commitHash}`,
|
|
}),
|
|
new CopyWebpackPlugin([
|
|
{ from: "./client/src/favicon.ico", to: "favicon.ico" },
|
|
]),
|
|
new ExtractTextPlugin("[name].css"),
|
|
],
|
|
output: {
|
|
filename: "[name].bundle.js",
|
|
path: path.resolve(__dirname, "../client/public"),
|
|
},
|
|
module: {
|
|
rules: [
|
|
{
|
|
test: /\.css$/,
|
|
use: ExtractTextPlugin.extract({
|
|
fallback: "style-loader",
|
|
use: [{ loader: "css-loader" }],
|
|
}),
|
|
},
|
|
],
|
|
},
|
|
};
|