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');
|
|
|
|
const CleanWebpackPlugin = require('clean-webpack-plugin');
|
|
|
|
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-08-24 04:34:18 +00:00
|
|
|
|
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: {
|
|
|
|
filename: '[name].[hash].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$/,
|
|
|
|
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$/,
|
2020-04-10 21:54:53 +00:00
|
|
|
use: 'file-loader',
|
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: {
|
|
|
|
contentBase: path.join(__dirname, '.tmp'),
|
|
|
|
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-08-10 04:59:47 +00:00
|
|
|
writeToDisk: true,
|
2021-02-26 15:50:33 +00:00
|
|
|
},
|
2019-03-21 05:46:49 +00:00
|
|
|
plugins: [
|
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
|
|
|
}),
|
|
|
|
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({
|
|
|
|
filename: '[name].[hash].css',
|
|
|
|
chunkFilename: '[name].[id].css',
|
|
|
|
}),
|
|
|
|
new CleanWebpackPlugin(['dist/public']),
|
|
|
|
new IgnorePlugin(/^\.\/locale$/, /moment$/),
|
|
|
|
// 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
|
|
|
}),
|
2019-03-21 05:46:49 +00:00
|
|
|
],
|
|
|
|
optimization: {
|
|
|
|
splitChunks: {
|
|
|
|
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'),
|
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
|
|
|
},
|
|
|
|
};
|