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

69 lines
1.3 KiB
JavaScript
Raw 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 = {
2022-07-13 03:58:11 +02:00
entry: {
app: path.join(__dirname, 'src', 'index.tsx'),
},
target: 'web',
resolve: {
extensions: ['.ts', '.tsx', '.js', '.jsx'],
},
output: {
filename: '[name].bundle.js',
path: path.resolve(__dirname, 'dist'),
},
module: {
rules: [
{
test: /\.tsx?$/,
use: 'ts-loader',
exclude: '/node_modules/',
},
{
test: /\.(png|jpe?g|gif|svg)$/,
type: 'asset/inline',
},
{
test: /\.wxml$/i,
type: 'asset/source',
},
],
},
optimization: {
usedExports: true,
splitChunks: {
cacheGroups: {
vendors: {
test: /node_modules\/.*/,
name: 'vendors',
chunks: 'all',
2022-01-26 20:25:11 +01:00
},
2022-07-13 03:58:11 +02:00
},
2021-02-16 20:11:13 +01:00
},
2022-07-13 03:58:11 +02:00
},
plugins: [
new CleanWebpackPlugin({
dangerouslyAllowCleanPatternsOutsideProject: true,
dry: false,
}),
new CopyWebpackPlugin({
patterns: [
{
from: 'public/*',
to: '[name].[ext]',
globOptions: {
ignore: ['**/index.html'],
},
},
],
}),
],
2022-01-26 20:25:11 +01:00
};