|
|
|
@ -1,12 +1,8 @@ |
|
|
|
const path = require("path"); |
|
|
|
const path = require("path"); |
|
|
|
const webpack = require("webpack"); |
|
|
|
const webpack = require("webpack"); |
|
|
|
const { CleanWebpackPlugin } = require("clean-webpack-plugin"); |
|
|
|
|
|
|
|
const HtmlWebpackPlugin = require("html-webpack-plugin"); |
|
|
|
const HtmlWebpackPlugin = require("html-webpack-plugin"); |
|
|
|
const HtmlWebpackInjector = require("html-webpack-injector"); |
|
|
|
const HtmlWebpackInjector = require("html-webpack-injector"); |
|
|
|
const CopyWebpackPlugin = require("copy-webpack-plugin"); |
|
|
|
|
|
|
|
const MiniCssExtractPlugin = require("mini-css-extract-plugin"); |
|
|
|
const MiniCssExtractPlugin = require("mini-css-extract-plugin"); |
|
|
|
const TerserPlugin = require("terser-webpack-plugin"); |
|
|
|
|
|
|
|
const pjson = require("../package.json"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const NODE_ENV = process.env.NODE_ENV == null ? "development" : process.env.NODE_ENV; |
|
|
|
const NODE_ENV = process.env.NODE_ENV == null ? "development" : process.env.NODE_ENV; |
|
|
|
|
|
|
|
|
|
|
|
@ -35,7 +31,7 @@ const moduleRules = [ |
|
|
|
test: /.(ttf|otf|eot|svg|woff(2)?)(\?[a-z0-9]+)?$/, |
|
|
|
test: /.(ttf|otf|eot|svg|woff(2)?)(\?[a-z0-9]+)?$/, |
|
|
|
exclude: /loading(|-white).svg/, |
|
|
|
exclude: /loading(|-white).svg/, |
|
|
|
generator: { |
|
|
|
generator: { |
|
|
|
filename: "fonts/[name][ext]", |
|
|
|
filename: "fonts/[name].[contenthash][ext]", |
|
|
|
}, |
|
|
|
}, |
|
|
|
type: "asset/resource", |
|
|
|
type: "asset/resource", |
|
|
|
}, |
|
|
|
}, |
|
|
|
@ -43,7 +39,7 @@ const moduleRules = [ |
|
|
|
test: /\.(jpe?g|png|gif|svg|webp|avif)$/i, |
|
|
|
test: /\.(jpe?g|png|gif|svg|webp|avif)$/i, |
|
|
|
exclude: /.*(fontawesome-webfont)\.svg/, |
|
|
|
exclude: /.*(fontawesome-webfont)\.svg/, |
|
|
|
generator: { |
|
|
|
generator: { |
|
|
|
filename: "images/[name][ext]", |
|
|
|
filename: "images/[name].[contenthash][ext]", |
|
|
|
}, |
|
|
|
}, |
|
|
|
type: "asset/resource", |
|
|
|
type: "asset/resource", |
|
|
|
}, |
|
|
|
}, |
|
|
|
@ -64,42 +60,47 @@ const plugins = [ |
|
|
|
new HtmlWebpackPlugin({ |
|
|
|
new HtmlWebpackPlugin({ |
|
|
|
template: "./src/duo.html", |
|
|
|
template: "./src/duo.html", |
|
|
|
filename: "duo.html", |
|
|
|
filename: "duo.html", |
|
|
|
chunks: ["connectors/duo"], |
|
|
|
chunks: ["duo"], |
|
|
|
}), |
|
|
|
}), |
|
|
|
new HtmlWebpackPlugin({ |
|
|
|
new HtmlWebpackPlugin({ |
|
|
|
template: "./src/webauthn.html", |
|
|
|
template: "./src/webauthn.html", |
|
|
|
filename: "webauthn.html", |
|
|
|
filename: "webauthn.html", |
|
|
|
chunks: ["connectors/webauthn"], |
|
|
|
chunks: ["webauthn"], |
|
|
|
}), |
|
|
|
}), |
|
|
|
new HtmlWebpackPlugin({ |
|
|
|
new HtmlWebpackPlugin({ |
|
|
|
template: "./src/webauthn-mobile.html", |
|
|
|
template: "./src/webauthn-mobile.html", |
|
|
|
filename: "webauthn-mobile.html", |
|
|
|
filename: "webauthn-mobile.html", |
|
|
|
chunks: ["connectors/webauthn"], |
|
|
|
chunks: ["webauthn"], |
|
|
|
}), |
|
|
|
}), |
|
|
|
new HtmlWebpackPlugin({ |
|
|
|
new HtmlWebpackPlugin({ |
|
|
|
template: "./src/webauthn-fallback.html", |
|
|
|
template: "./src/webauthn-fallback.html", |
|
|
|
filename: "webauthn-fallback.html", |
|
|
|
filename: "webauthn-fallback.html", |
|
|
|
chunks: ["connectors/webauthn-fallback"], |
|
|
|
chunks: ["webauthn-fallback"], |
|
|
|
}), |
|
|
|
}), |
|
|
|
new HtmlWebpackPlugin({ |
|
|
|
new HtmlWebpackPlugin({ |
|
|
|
template: "./src/sso.html", |
|
|
|
template: "./src/sso.html", |
|
|
|
filename: "sso.html", |
|
|
|
filename: "sso.html", |
|
|
|
chunks: ["connectors/sso"], |
|
|
|
chunks: ["sso"], |
|
|
|
}), |
|
|
|
}), |
|
|
|
new HtmlWebpackPlugin({ |
|
|
|
new HtmlWebpackPlugin({ |
|
|
|
template: "./src/captcha.html", |
|
|
|
template: "./src/captcha.html", |
|
|
|
filename: "captcha.html", |
|
|
|
filename: "captcha.html", |
|
|
|
chunks: ["connectors/captcha"], |
|
|
|
chunks: ["captcha"], |
|
|
|
}), |
|
|
|
}), |
|
|
|
new HtmlWebpackPlugin({ |
|
|
|
new HtmlWebpackPlugin({ |
|
|
|
template: "./src/captcha-mobile.html", |
|
|
|
template: "./src/captcha-mobile.html", |
|
|
|
filename: "captcha-mobile.html", |
|
|
|
filename: "captcha-mobile.html", |
|
|
|
chunks: ["connectors/captcha"], |
|
|
|
chunks: ["captcha"], |
|
|
|
}), |
|
|
|
}), |
|
|
|
|
|
|
|
|
|
|
|
new MiniCssExtractPlugin({ |
|
|
|
new MiniCssExtractPlugin({ |
|
|
|
filename: "[name].[contenthash].css", |
|
|
|
filename: "assets/[name].[contenthash].css", |
|
|
|
chunkFilename: "[id].[contenthash].css", |
|
|
|
chunkFilename: "assets/[id].[contenthash].css", |
|
|
|
|
|
|
|
}), |
|
|
|
|
|
|
|
new webpack.EnvironmentPlugin({ |
|
|
|
|
|
|
|
CACHE_TAG: Math.random().toString(36).substring(7), |
|
|
|
|
|
|
|
}), |
|
|
|
|
|
|
|
new webpack.ProvidePlugin({ |
|
|
|
|
|
|
|
process: "process/browser", |
|
|
|
}), |
|
|
|
}), |
|
|
|
]; |
|
|
|
]; |
|
|
|
|
|
|
|
|
|
|
|
@ -107,11 +108,11 @@ const webpackConfig = { |
|
|
|
mode: NODE_ENV, |
|
|
|
mode: NODE_ENV, |
|
|
|
devtool: "source-map", |
|
|
|
devtool: "source-map", |
|
|
|
entry: { |
|
|
|
entry: { |
|
|
|
"connectors/webauthn": "./src/webauthn/webauthn.ts", |
|
|
|
webauthn: "./src/webauthn/webauthn.ts", |
|
|
|
"connectors/webauthn-fallback": "./src/webauthn/webauthn-fallback.ts", |
|
|
|
"webauthn-fallback": "./src/webauthn/webauthn-fallback.ts", |
|
|
|
"connectors/duo": "./src/duo/duo.ts", |
|
|
|
duo: "./src/duo/duo.ts", |
|
|
|
"connectors/sso": "./src/sso/sso.ts", |
|
|
|
sso: "./src/sso/sso.ts", |
|
|
|
"connectors/captcha": "./src/captcha/captcha.ts", |
|
|
|
captcha: "./src/captcha/captcha.ts", |
|
|
|
}, |
|
|
|
}, |
|
|
|
optimization: { |
|
|
|
optimization: { |
|
|
|
splitChunks: { |
|
|
|
splitChunks: { |
|
|
|
@ -125,13 +126,6 @@ const webpackConfig = { |
|
|
|
}, |
|
|
|
}, |
|
|
|
}, |
|
|
|
}, |
|
|
|
}, |
|
|
|
}, |
|
|
|
minimizer: [ |
|
|
|
|
|
|
|
new TerserPlugin({ |
|
|
|
|
|
|
|
terserOptions: { |
|
|
|
|
|
|
|
safari10: true, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
}), |
|
|
|
|
|
|
|
], |
|
|
|
|
|
|
|
}, |
|
|
|
}, |
|
|
|
resolve: { |
|
|
|
resolve: { |
|
|
|
extensions: [".ts", ".js"], |
|
|
|
extensions: [".ts", ".js"], |
|
|
|
@ -144,8 +138,9 @@ const webpackConfig = { |
|
|
|
}, |
|
|
|
}, |
|
|
|
}, |
|
|
|
}, |
|
|
|
output: { |
|
|
|
output: { |
|
|
|
filename: "[name].[contenthash].js", |
|
|
|
filename: "assets/[name].[contenthash].js", |
|
|
|
path: path.resolve(__dirname, "build"), |
|
|
|
path: path.resolve(__dirname, "build"), |
|
|
|
|
|
|
|
publicPath: "/connectors/", |
|
|
|
clean: true, |
|
|
|
clean: true, |
|
|
|
}, |
|
|
|
}, |
|
|
|
module: { rules: moduleRules }, |
|
|
|
module: { rules: moduleRules }, |
|
|
|
|