build: use commonjs config for webpack (#449)

This commit is contained in:
Adam Uhlíř
2022-06-28 12:28:53 +02:00
committed by GitHub
parent 58bea4e7a8
commit ec13357666
3 changed files with 4 additions and 33 deletions
+61
View File
@@ -0,0 +1,61 @@
// eslint-disable-next-line @typescript-eslint/no-var-requires
const Path = require('path')
// eslint-disable-next-line import/no-anonymous-default-export
module.exports = () => {
const entry = Path.resolve(__dirname, 'src', 'App.tsx')
return {
mode: 'production',
entry,
output: {
path: Path.resolve(__dirname, 'lib'),
filename: 'App.js',
library: 'beeDashboard',
libraryTarget: 'umd',
},
resolve: {
extensions: ['.css', '.png', '.svg', '.ttf', '.ts', '.tsx', '.js'],
},
devtool: 'source-map',
externals: {
// Use external version of React
// react: 'root React',
react: 'react',
'react-dom': 'react-dom',
},
target: 'web',
optimization: {
minimize: false,
},
module: {
rules: [
{
test: /\.css$/i,
use: ['style-loader', 'css-loader'],
},
{
test: /\.(png|jp(e*)g|svg|gif)$/,
loader: 'file-loader',
options: {
name: 'assets/[name].[ext]',
},
},
{
test: /\.(ttf)$/,
loader: 'file-loader',
options: {
name: 'assets/fonts/[name].[ext]',
},
},
{
test: /\.(ts|js|tsx|jsx)$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
},
},
],
},
}
}