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');
|
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: {
|
2020-04-10 21:54:53 +00:00
|
|
|
main: './app/__module.js',
|
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) => {
|
|
|
|
// ignores `chardet` missing sourcemaps
|
|
|
|
return !/node_modules\/chardet/i.test(resourcePath);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
2021-01-12 21:40:09 +00:00
|
|
|
},
|
2019-03-21 05:46:49 +00:00
|
|
|
{
|
|
|
|
test: /\.js$/,
|
|
|
|
exclude: /node_modules/,
|
|
|
|
use: [
|
|
|
|
'babel-loader',
|
|
|
|
'auto-ngtemplate-loader',
|
|
|
|
{
|
|
|
|
// enforce: 'pre',
|
2020-04-10 21:54:53 +00:00
|
|
|
loader: 'eslint-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$/,
|
2020-04-10 21:54:53 +00:00
|
|
|
use: [MiniCssExtractPlugin.loader, { loader: 'css-loader', options: { importLoaders: 1 } }, 'postcss-loader'],
|
|
|
|
},
|
|
|
|
],
|
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: {
|
|
|
|
'/api': 'http://localhost:9000',
|
|
|
|
},
|
|
|
|
open: true,
|
|
|
|
},
|
2019-03-21 05:46:49 +00:00
|
|
|
plugins: [
|
|
|
|
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',
|
2020-04-10 21:54:53 +00:00
|
|
|
sourceMap: true,
|
2019-03-21 05:46:49 +00:00
|
|
|
}),
|
|
|
|
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
|
|
|
},
|
2019-03-21 05:46:49 +00:00
|
|
|
},
|
|
|
|
};
|