2019-03-21 05:46:49 +00:00
|
|
|
const path = require('path');
|
2020-08-06 22:46:25 +00:00
|
|
|
const { ProvidePlugin, IgnorePlugin } = require('webpack');
|
2019-03-21 05:46:49 +00:00
|
|
|
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
|
|
|
const WebpackBuildNotifierPlugin = require('webpack-build-notifier');
|
|
|
|
const CleanTerminalPlugin = require('clean-terminal-webpack-plugin');
|
|
|
|
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
2021-12-16 18:52:54 +00:00
|
|
|
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
|
2019-03-21 05:46:49 +00:00
|
|
|
const LodashModuleReplacementPlugin = require('lodash-webpack-plugin');
|
2021-08-24 04:34:18 +00:00
|
|
|
const ESLintPlugin = require('eslint-webpack-plugin');
|
2021-11-03 10:41:59 +00:00
|
|
|
const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin');
|
2021-12-15 09:43:49 +00:00
|
|
|
const Dotenv = require('dotenv-webpack');
|
2021-08-24 04:34:18 +00:00
|
|
|
|
2022-01-10 13:22:21 +00:00
|
|
|
const CopyPlugin = require('copy-webpack-plugin');
|
2020-04-14 23:46:34 +00:00
|
|
|
const pkg = require('../package.json');
|
2019-03-21 05:46:49 +00:00
|
|
|
const projectRoot = path.resolve(__dirname, '..');
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
entry: {
|
2021-12-09 07:38:07 +00:00
|
|
|
main: './app',
|
2019-03-21 05:46:49 +00:00
|
|
|
},
|
|
|
|
output: {
|
2021-12-16 18:52:54 +00:00
|
|
|
filename: '[name].[contenthash].js',
|
2020-04-10 21:54:53 +00:00
|
|
|
path: path.resolve(projectRoot, 'dist/public'),
|
2019-03-21 05:46:49 +00:00
|
|
|
},
|
|
|
|
module: {
|
|
|
|
rules: [
|
2021-01-12 21:40:09 +00:00
|
|
|
{
|
|
|
|
test: /\.js$/,
|
2021-12-16 18:52:54 +00:00
|
|
|
type: 'javascript/auto',
|
2021-01-12 21:40:09 +00:00
|
|
|
enforce: 'pre',
|
2021-04-05 21:12:51 +00:00
|
|
|
use: [
|
|
|
|
{
|
|
|
|
loader: 'source-map-loader',
|
|
|
|
options: {
|
|
|
|
filterSourceMappingUrl: (_, resourcePath) => {
|
2021-07-14 09:15:21 +00:00
|
|
|
// ignores pkgs missing sourcemaps
|
|
|
|
return ['chardet', 'tokenize-ansi'].every((pkg) => !resourcePath.includes(pkg));
|
2021-04-05 21:12:51 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
2021-01-12 21:40:09 +00:00
|
|
|
},
|
2019-03-21 05:46:49 +00:00
|
|
|
{
|
2021-11-03 10:41:59 +00:00
|
|
|
test: /\.(js|ts)(x)?$/,
|
2019-03-21 05:46:49 +00:00
|
|
|
exclude: /node_modules/,
|
2021-08-24 04:34:18 +00:00
|
|
|
use: ['babel-loader', 'auto-ngtemplate-loader'],
|
2019-03-21 05:46:49 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.html$/,
|
|
|
|
exclude: path.resolve(projectRoot, './app/index.html'),
|
|
|
|
use: [
|
|
|
|
{
|
|
|
|
loader: 'ngtemplate-loader',
|
|
|
|
options: {
|
2020-04-10 21:54:53 +00:00
|
|
|
relativeTo: projectRoot + '/',
|
|
|
|
},
|
2019-03-21 05:46:49 +00:00
|
|
|
},
|
2020-04-10 21:54:53 +00:00
|
|
|
{ loader: 'html-loader' },
|
|
|
|
],
|
2019-03-21 05:46:49 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
test: /.xml$/,
|
2021-12-16 18:52:54 +00:00
|
|
|
type: 'asset/resource',
|
2019-03-21 05:46:49 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.css$/,
|
2021-11-03 10:41:59 +00:00
|
|
|
use: [
|
|
|
|
MiniCssExtractPlugin.loader,
|
|
|
|
{
|
|
|
|
loader: 'css-loader',
|
|
|
|
options: {
|
|
|
|
importLoaders: 1,
|
|
|
|
modules: {
|
|
|
|
localIdentName: '[path][name]__[local]',
|
|
|
|
auto: true,
|
|
|
|
exportLocalsConvention: 'camelCaseOnly',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
'postcss-loader',
|
|
|
|
],
|
2020-04-10 21:54:53 +00:00
|
|
|
},
|
|
|
|
],
|
2019-03-21 05:46:49 +00:00
|
|
|
},
|
2021-02-26 15:50:33 +00:00
|
|
|
devServer: {
|
2021-12-16 18:52:54 +00:00
|
|
|
static: {
|
|
|
|
directory: path.join(__dirname, 'public'),
|
|
|
|
},
|
2021-02-26 15:50:33 +00:00
|
|
|
compress: true,
|
|
|
|
port: 8999,
|
|
|
|
proxy: {
|
2021-09-15 05:55:06 +00:00
|
|
|
'/api': 'http://localhost:9000',
|
2021-02-26 15:50:33 +00:00
|
|
|
},
|
|
|
|
open: true,
|
2021-12-16 18:52:54 +00:00
|
|
|
devMiddleware: {
|
|
|
|
writeToDisk: true,
|
|
|
|
},
|
2021-02-26 15:50:33 +00:00
|
|
|
},
|
2019-03-21 05:46:49 +00:00
|
|
|
plugins: [
|
2022-01-24 06:02:23 +00:00
|
|
|
new Dotenv({ defaults: true }),
|
2021-08-24 04:34:18 +00:00
|
|
|
new ESLintPlugin(),
|
2019-03-21 05:46:49 +00:00
|
|
|
new HtmlWebpackPlugin({
|
|
|
|
template: './app/index.html',
|
|
|
|
templateParameters: {
|
2020-04-14 23:46:34 +00:00
|
|
|
name: pkg.name,
|
|
|
|
author: pkg.author,
|
2019-03-21 05:46:49 +00:00
|
|
|
},
|
2020-04-10 21:54:53 +00:00
|
|
|
manifest: './assets/ico/manifest.json',
|
2019-03-21 05:46:49 +00:00
|
|
|
}),
|
2022-04-05 04:29:57 +00:00
|
|
|
new HtmlWebpackPlugin({
|
|
|
|
template: './app/timeout.ejs',
|
|
|
|
filename: 'timeout.html',
|
|
|
|
templateParameters: {
|
|
|
|
name: pkg.name,
|
|
|
|
author: pkg.author,
|
|
|
|
},
|
|
|
|
}),
|
2019-03-21 05:46:49 +00:00
|
|
|
new WebpackBuildNotifierPlugin({
|
|
|
|
title: 'Portainer build',
|
|
|
|
logo: path.resolve('./assets/favicon-32x32.png'),
|
2020-04-10 21:54:53 +00:00
|
|
|
suppressSuccess: true,
|
2019-03-21 05:46:49 +00:00
|
|
|
}),
|
|
|
|
new CleanTerminalPlugin(),
|
|
|
|
new ProvidePlugin({
|
|
|
|
$: 'jquery',
|
|
|
|
jQuery: 'jquery',
|
|
|
|
'window.jQuery': 'jquery',
|
|
|
|
'window.moment': 'moment',
|
|
|
|
moment: 'moment',
|
|
|
|
'window.jsyaml': 'js-yaml',
|
2020-04-10 21:54:53 +00:00
|
|
|
jsyaml: 'js-yaml',
|
2019-03-21 05:46:49 +00:00
|
|
|
}),
|
|
|
|
new MiniCssExtractPlugin({
|
2021-12-16 18:52:54 +00:00
|
|
|
filename: '[name].[contenthash].css',
|
2019-03-21 05:46:49 +00:00
|
|
|
chunkFilename: '[name].[id].css',
|
|
|
|
}),
|
2021-12-16 18:52:54 +00:00
|
|
|
new CleanWebpackPlugin(),
|
|
|
|
new IgnorePlugin({ resourceRegExp: /^.\/locale$/, contextRegExp: /moment$/ }),
|
2019-03-21 05:46:49 +00:00
|
|
|
// new BundleAnalyzerPlugin()
|
|
|
|
new LodashModuleReplacementPlugin({
|
2019-04-08 00:35:02 +00:00
|
|
|
shorthands: true,
|
2019-11-27 20:35:14 +00:00
|
|
|
collections: true,
|
2020-04-10 21:54:53 +00:00
|
|
|
paths: true,
|
2019-06-02 06:16:07 +00:00
|
|
|
}),
|
2022-01-10 13:22:21 +00:00
|
|
|
new CopyPlugin({
|
|
|
|
patterns: [
|
|
|
|
{
|
|
|
|
from: 'translations',
|
|
|
|
to: 'locales',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
}),
|
2019-03-21 05:46:49 +00:00
|
|
|
],
|
|
|
|
optimization: {
|
2021-12-16 18:52:54 +00:00
|
|
|
moduleIds: 'deterministic',
|
|
|
|
runtimeChunk: 'single',
|
2019-03-21 05:46:49 +00:00
|
|
|
splitChunks: {
|
2021-12-16 18:52:54 +00:00
|
|
|
chunks: 'all',
|
2019-03-21 05:46:49 +00:00
|
|
|
cacheGroups: {
|
|
|
|
vendor: {
|
|
|
|
test: /node_modules/,
|
|
|
|
chunks: 'initial',
|
|
|
|
name: 'vendor',
|
|
|
|
priority: 10,
|
2020-04-10 21:54:53 +00:00
|
|
|
enforce: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-03-21 05:46:49 +00:00
|
|
|
},
|
|
|
|
resolve: {
|
|
|
|
alias: {
|
|
|
|
Agent: path.resolve(projectRoot, 'app/agent'),
|
2020-06-09 02:43:32 +00:00
|
|
|
Azure: path.resolve(projectRoot, 'app/azure'),
|
2019-03-21 05:46:49 +00:00
|
|
|
Docker: path.resolve(projectRoot, 'app/docker'),
|
2020-07-05 23:21:03 +00:00
|
|
|
Kubernetes: path.resolve(projectRoot, 'app/kubernetes'),
|
2019-03-21 05:46:49 +00:00
|
|
|
Portainer: path.resolve(projectRoot, 'app/portainer'),
|
2020-06-04 23:03:13 +00:00
|
|
|
'@': path.resolve(projectRoot, 'app'),
|
2021-12-21 12:32:48 +00:00
|
|
|
'lodash-es': 'lodash',
|
2020-04-10 21:54:53 +00:00
|
|
|
},
|
2021-11-03 10:41:59 +00:00
|
|
|
extensions: ['.js', '.ts', '.tsx'],
|
|
|
|
plugins: [
|
|
|
|
new TsconfigPathsPlugin({
|
|
|
|
extensions: ['.js', '.ts', '.tsx'],
|
|
|
|
}),
|
|
|
|
],
|
2019-03-21 05:46:49 +00:00
|
|
|
},
|
|
|
|
};
|