cinny/webpack.common.js

67 lines
1.6 KiB
JavaScript
Raw Normal View History

2021-07-28 15:15:52 +02:00
const HtmlWebpackPlugin = require('html-webpack-plugin');
const CopyPlugin = require("copy-webpack-plugin");
const webpack = require('webpack');
2021-07-28 15:15:52 +02:00
module.exports = {
entry: {
polyfill: 'babel-polyfill',
main: './src/index.jsx'
},
resolve: {
extensions: ['.js', '.jsx'],
fallback: {
'crypto': require.resolve('crypto-browserify'),
'path': require.resolve('path-browserify'),
'fs': require.resolve('browserify-fs'),
'stream': require.resolve('stream-browserify'),
'util': require.resolve('util/'),
'assert': require.resolve('assert/'),
'url': require.resolve('url/'),
'buffer': require.resolve('buffer'),
2021-07-28 15:15:52 +02:00
}
},
node: {
global: true,
},
module: {
rules: [
{
test: /\.jsx?$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env', '@babel/preset-react'],
},
},
},
{
test: /\.html$/,
use: ['html-loader'],
},
{
test: /\.(png|jpe?g|gif|otf|ttf|woff|woff2|ogg)$/,
type: 'asset/resource',
2021-07-28 15:15:52 +02:00
},
{
test: /\.svg$/,
type: 'asset/inline',
}
2021-07-28 15:15:52 +02:00
],
},
plugins: [
new HtmlWebpackPlugin({ template: './public/index.html' }),
new CopyPlugin({
patterns: [
{ from: 'node_modules/@matrix-org/olm/olm.wasm' },
{ from: '_redirects' },
{ from: 'config.json' },
{ from: 'public/res/android'}
],
}),
new webpack.ProvidePlugin({
Buffer: ['buffer', 'Buffer'],
}),
2021-07-28 15:15:52 +02:00
],
};