grid/webpack.config.js

73 lines
2.1 KiB
JavaScript
Raw Normal View History

const path = require('path');
2023-01-09 23:13:06 +00:00
const HtmlWebpackPlugin = require('html-webpack-plugin');
2023-01-09 23:38:02 +00:00
function relpath(fp) {
return path.resolve(__dirname, ...fp.split('/'));
}
module.exports = {
2023-01-10 00:01:59 +00:00
// note: production disables the in-memory cache
mode: 'development', // 'production',
2023-01-09 23:13:06 +00:00
entry: {
2023-01-09 23:38:02 +00:00
index: relpath('src/index.js'),
2023-01-09 23:13:06 +00:00
},
2023-01-10 00:01:59 +00:00
// enable source mapping (disable for much smaller files)
2023-01-09 23:23:16 +00:00
devtool: 'inline-source-map',
2023-01-10 00:01:59 +00:00
// auto-generate index.html file with webpack bundles
2023-01-09 23:13:06 +00:00
plugins: [
new HtmlWebpackPlugin({
title: 'Example Webapp',
2023-01-09 23:38:02 +00:00
template: relpath('src/index.html'),
2023-01-09 23:13:06 +00:00
}),
],
output: {
2023-01-09 23:13:06 +00:00
clean: true,
2023-01-09 23:56:03 +00:00
filename: '[name].[contenthash].bundle.js',
2023-01-09 23:38:02 +00:00
path: relpath('dist'),
},
devServer: {
static: relpath('dist'),
},
optimization: {
runtimeChunk: 'single',
2023-01-10 00:01:59 +00:00
// enable caching with vendors in a seperate chunk
moduleIds: 'deterministic',
2023-01-09 23:56:03 +00:00
splitChunks: {
cacheGroups: {
vendor: {
test: /[\\/]node_modules[\\/]/,
name: 'vendors',
chunks: 'all',
},
},
},
2023-01-09 23:38:02 +00:00
},
performance: {
// hides the performance warnings for now
2023-01-10 00:01:59 +00:00
// these are especially apparent with source maps enabled
2023-01-09 23:38:02 +00:00
hints: false,
},
2023-01-09 22:35:07 +00:00
module: {
rules: [
2023-01-09 22:56:10 +00:00
// sass support with `import './styles.scss'`
2023-01-09 22:35:07 +00:00
{
2023-01-10 00:01:59 +00:00
include: relpath('src'),
2023-01-09 22:35:07 +00:00
test: /\.s[ac]ss$/i,
use: ['style-loader', 'css-loader', 'sass-loader'],
},
2023-01-09 22:56:10 +00:00
// css support with `import './styles.css'`
{
2023-01-10 00:01:59 +00:00
include: relpath('src'),
2023-01-09 23:01:06 +00:00
test: /\.css$/i,
2023-01-09 22:56:10 +00:00
use: ['style-loader', 'css-loader'],
},
// image support with `import Image from './image.png'`
{
2023-01-10 00:01:59 +00:00
include: relpath('src'),
2023-01-09 22:56:10 +00:00
test: /\.(png|svg|jpg|jpeg|gif)$/i,
type: 'asset/resource',
},
2023-01-09 22:35:07 +00:00
],
},
};