wisemapping-frontend/packages/webapp/webpack.common.js

65 lines
1.5 KiB
JavaScript
Raw Permalink Normal View History

2021-02-17 09:11:08 +01:00
/* eslint-disable no-undef */
const path = require('path');
2022-01-26 20:25:11 +01:00
const webpack = require('webpack');
2021-02-16 21:01:32 +01:00
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
2020-12-09 04:35:02 +01:00
2022-01-26 20:25:11 +01:00
webpack;
2021-02-16 21:01:32 +01:00
module.exports = {
2020-12-07 01:31:48 +01:00
entry: {
2022-01-26 20:25:11 +01:00
app: path.join(__dirname, 'src', 'index.tsx'),
2020-12-07 01:31:48 +01:00
},
target: 'web',
resolve: {
2022-01-26 20:25:11 +01:00
extensions: ['.ts', '.tsx', '.js', '.jsx'],
2020-12-07 01:31:48 +01:00
},
2021-02-16 20:11:13 +01:00
output: {
filename: '[name].bundle.js',
2022-01-26 20:25:11 +01:00
path: path.resolve(__dirname, 'dist'),
2021-02-16 20:11:13 +01:00
},
2020-12-07 01:31:48 +01:00
module: {
2022-01-26 20:25:11 +01:00
rules: [
{
test: /\.tsx?$/,
use: 'ts-loader',
exclude: '/node_modules/',
},
{
test: /\.(png|jpe?g|gif|svg)$/,
type: 'asset/inline',
},
],
2020-12-07 01:31:48 +01:00
},
2021-02-16 20:11:13 +01:00
optimization: {
usedExports: true,
splitChunks: {
cacheGroups: {
vendors: {
2021-02-26 08:01:12 +01:00
test: /node_modules\/.*/,
2022-01-26 20:25:11 +01:00
name: 'vendors',
chunks: 'all',
},
2021-02-16 20:11:13 +01:00
},
2022-01-26 20:25:11 +01:00
},
2021-02-16 20:11:13 +01:00
},
2020-12-07 01:31:48 +01:00
plugins: [
2022-02-05 22:53:10 +01:00
new CleanWebpackPlugin({
dangerouslyAllowCleanPatternsOutsideProject: true,
dry: false,
}),
new CopyWebpackPlugin({
2022-01-26 20:25:11 +01:00
patterns: [
{
from: 'public/*',
to: '[name].[ext]',
globOptions: {
ignore: ['**/index.html'],
},
},
],
}),
],
};