Files
storage-service-ui/webpack.config.js

97 lines
2.7 KiB
JavaScript

// eslint-disable-next-line no-undef
const path = require('path');
// eslint-disable-next-line no-undef
const HtmlWebpackPlugin = require('html-webpack-plugin');
// eslint-disable-next-line no-undef
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
// eslint-disable-next-line no-undef
const {CleanWebpackPlugin} = require('clean-webpack-plugin');
// eslint-disable-next-line no-undef
module.exports = (env, argv) => ({
entry: './src/app.js',
output: {
filename: '[hash].js',
// eslint-disable-next-line no-undef
path: path.resolve(__dirname, 'dist'),
},
devServer: {
compress: true,
port: 9000,
},
optimization: {
splitChunks: {
chunks: 'all',
cacheGroups: {
defaultVendors: {
test: /[\\/]node_modules[\\/]/,
enforce: true,
},
}
},
},
plugins: [
new CleanWebpackPlugin(),
new HtmlWebpackPlugin({
filename: 'index.html',
template: './src/app.html'
}),
new MiniCssExtractPlugin({
filename: '[hash].css',
}),
],
module: {
rules: [
{
test: /\.html$/i,
loader: 'html-loader',
},
{
test: /\.css$/i,
use: [
MiniCssExtractPlugin.loader,
'css-loader',
'postcss-loader'
],
},
{
test: /\.js$/,
exclude: /node_modules/,
use: [
'babel-loader',
{
loader: 'eslint-loader',
options: (argv.mode === 'production') ? {
failOnError: true,
failOnWarning: true,
} : {},
}
]
},
{
test: /\.(gif|png|jpe?g|svg)$/i,
use: [
{
loader: 'image-webpack-loader',
options: {
quality: 80
},
},
{
loader: 'url-loader',
options: {
limit: 200000,
},
},
],
},
{
test: /\.(woff|woff2|eot|ttf|otf)$/,
use: [
'file-loader',
],
},
],
},
});