2020-12-05 08:47:02 +01:00
|
|
|
const path = require('path');
|
2021-02-16 21:01:32 +01:00
|
|
|
const webpack = require('webpack')
|
|
|
|
|
2020-12-05 08:47:02 +01:00
|
|
|
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
|
2020-12-12 21:23:38 +01:00
|
|
|
const CopyWebpackPlugin = require('copy-webpack-plugin');
|
2020-12-09 04:35:02 +01:00
|
|
|
|
2021-02-16 21:01:32 +01:00
|
|
|
webpack
|
|
|
|
|
2020-12-05 08:47:02 +01:00
|
|
|
module.exports = {
|
2020-12-07 01:31:48 +01:00
|
|
|
entry: {
|
|
|
|
app: path.join(__dirname, 'src', 'index.tsx')
|
|
|
|
},
|
|
|
|
target: 'web',
|
|
|
|
resolve: {
|
|
|
|
extensions: ['.ts', '.tsx', '.js', '.jsx']
|
|
|
|
},
|
2021-02-16 20:11:13 +01:00
|
|
|
output: {
|
|
|
|
filename: '[name].bundle.js',
|
|
|
|
path: path.resolve(__dirname, 'dist')
|
|
|
|
},
|
2020-12-07 01:31:48 +01:00
|
|
|
module: {
|
2020-12-12 05:06:42 +01:00
|
|
|
rules: [{
|
2021-02-16 20:11:13 +01:00
|
|
|
test: /\.tsx?$/,
|
|
|
|
use: 'ts-loader',
|
|
|
|
exclude: '/node_modules/'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.(png|jpe?g|gif|svg)$/,
|
|
|
|
use: [{
|
|
|
|
loader: 'file-loader',
|
|
|
|
options: {
|
|
|
|
esModule: false,
|
2021-02-17 04:47:09 +01:00
|
|
|
name: '[name].[ext]',
|
2021-02-16 20:11:13 +01:00
|
|
|
}
|
|
|
|
}]
|
|
|
|
},
|
2020-12-07 01:31:48 +01:00
|
|
|
]
|
|
|
|
},
|
2021-02-16 20:11:13 +01:00
|
|
|
optimization: {
|
|
|
|
usedExports: true,
|
|
|
|
splitChunks: {
|
|
|
|
cacheGroups: {
|
|
|
|
vendors: {
|
2021-02-16 20:22:55 +01:00
|
|
|
test: /node_modules\/(?!@material-ui\/).*/,
|
2021-02-16 20:11:13 +01:00
|
|
|
name: "vendors",
|
|
|
|
chunks: "all",
|
|
|
|
},
|
2021-02-16 20:22:55 +01:00
|
|
|
material: {
|
|
|
|
test: /node_modules\/(@material-ui\/).*/,
|
|
|
|
name: "material-ui",
|
2021-02-16 20:11:13 +01:00
|
|
|
chunks: "all",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
},
|
2020-12-07 01:31:48 +01:00
|
|
|
plugins: [
|
|
|
|
new CleanWebpackPlugin(),
|
2020-12-12 21:23:38 +01:00
|
|
|
new CopyWebpackPlugin({
|
|
|
|
patterns: [{
|
2020-12-12 22:12:29 +01:00
|
|
|
from: 'public/*',
|
2020-12-16 03:04:12 +01:00
|
|
|
to: '[name].[ext]',
|
|
|
|
globOptions: {
|
|
|
|
ignore: [
|
|
|
|
'**/index.html'
|
|
|
|
]
|
|
|
|
}
|
2020-12-12 21:23:38 +01:00
|
|
|
}]
|
2021-02-16 22:07:54 +01:00
|
|
|
})]
|
2021-02-17 04:47:09 +01:00
|
|
|
}
|