113 lines
2.7 KiB
JavaScript
113 lines
2.7 KiB
JavaScript
const path = require('path');
|
|
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
|
const WebpackBuildNotifierPlugin = require('webpack-build-notifier');
|
|
const CleanTerminalPlugin = require('clean-terminal-webpack-plugin');
|
|
const { ProvidePlugin } = require('webpack');
|
|
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
|
const CleanWebpackPlugin = require('clean-webpack-plugin');
|
|
|
|
const npmPackage = require('./package.json');
|
|
module.exports = {
|
|
entry: {
|
|
main: './app/__module.js'
|
|
},
|
|
output: {
|
|
filename: '[name].[hash].js',
|
|
path: path.resolve(__dirname, 'dist/public')
|
|
},
|
|
module: {
|
|
rules: [
|
|
{
|
|
test: /\.js$/,
|
|
exclude: /node_modules/,
|
|
use: [
|
|
'auto-ngtemplate-loader',
|
|
{
|
|
// enforce: 'pre',
|
|
loader: 'eslint-loader'
|
|
}
|
|
]
|
|
},
|
|
{
|
|
test: /\.html$/,
|
|
exclude: path.resolve(__dirname, './app/index.html'),
|
|
use: [
|
|
{ loader: 'ngtemplate-loader', options: { relativeTo: __dirname } },
|
|
{ loader: 'html-loader' }
|
|
]
|
|
},
|
|
{
|
|
test: /\.(woff|woff2|eot|ttf|svg|)$/,
|
|
use: [
|
|
{
|
|
loader: 'url-loader',
|
|
options: { limit: 25000 }
|
|
}
|
|
]
|
|
},
|
|
{
|
|
test: /\.(ico|png|jpg|gif)$/,
|
|
use: [
|
|
{
|
|
loader: 'url-loader',
|
|
options: {
|
|
limit: 25000
|
|
}
|
|
}
|
|
]
|
|
},
|
|
{
|
|
test: /.xml$/,
|
|
use: 'file-loader'
|
|
},
|
|
{
|
|
test: /\.css$/,
|
|
use: [MiniCssExtractPlugin.loader, 'css-loader?sourceMap']
|
|
}
|
|
]
|
|
},
|
|
mode: 'development',
|
|
plugins: [
|
|
new HtmlWebpackPlugin({
|
|
template: './app/index.html',
|
|
templateParameters: {
|
|
name: npmPackage.name,
|
|
author: npmPackage.author
|
|
},
|
|
manifest: './assets/ico/manifest.json'
|
|
}),
|
|
new WebpackBuildNotifierPlugin({
|
|
title: 'Portainer build',
|
|
logo: path.resolve('./assets/favicon-32x32.png'),
|
|
suppressSuccess: true
|
|
}),
|
|
new CleanTerminalPlugin(),
|
|
new ProvidePlugin({
|
|
$: 'jquery',
|
|
jQuery: 'jquery',
|
|
'window.jQuery': 'jquery'
|
|
}),
|
|
new MiniCssExtractPlugin({
|
|
// Options similar to the same options in webpackOptions.output
|
|
// both options are optional
|
|
filename: '[name].css',
|
|
chunkFilename: '[id].css',
|
|
sourceMap: true
|
|
}),
|
|
new CleanWebpackPlugin(['dist/public'])
|
|
],
|
|
optimization: {
|
|
splitChunks: {
|
|
cacheGroups: {
|
|
vendor: {
|
|
test: /node_modules/,
|
|
chunks: 'initial',
|
|
name: 'vendor',
|
|
priority: 10,
|
|
enforce: true
|
|
}
|
|
}
|
|
}
|
|
}
|
|
};
|