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

68 lines
1.8 KiB
JavaScript
Raw Normal View History

const path = require('path');
2020-12-09 04:35:02 +01:00
const HtmlWebpackPlugin = require('html-webpack-plugin');
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
2020-12-09 04:35:02 +01:00
module.exports = {
2020-12-07 01:31:48 +01:00
mode: 'development',
devtool: 'eval-source-map',
entry: {
app: path.join(__dirname, 'src', 'index.tsx')
},
target: 'web',
resolve: {
extensions: ['.ts', '.tsx', '.js', '.jsx']
},
module: {
2020-12-12 05:06:42 +01:00
rules: [{
2020-12-07 01:31:48 +01:00
test: /\.tsx?$/,
use: 'ts-loader',
exclude: '/node_modules/'
2020-12-12 05:06:42 +01:00
},
2020-12-07 01:31:48 +01:00
{
test: /\.(png|jpe?g|gif|svg)$/,
use: [{
loader: 'file-loader',
options: {
esModule: false,
}
2020-12-12 05:06:42 +01:00
}]
2020-12-07 01:31:48 +01:00
}
]
},
output: {
filename: 'bundle.js',
path: path.resolve(__dirname, 'dist')
},
plugins: [
new CleanWebpackPlugin(),
// @FixMe: Fatten the dir ...
new CopyWebpackPlugin({
patterns: [{
2020-12-12 22:12:29 +01:00
from: 'public/*',
to: '[name].[ext]'
}]
}),
2020-12-07 01:31:48 +01:00
new HtmlWebpackPlugin({
2020-12-09 04:35:02 +01:00
template: path.join(__dirname, 'public/index.html'),
templateParameters: {
2020-12-09 04:44:12 +01:00
PUBLIC_URL: process.env.PUBLIC_URL ? process.env.PUBLIC_URL : 'http://localhost:3000'
2020-12-09 04:35:02 +01:00
},
base: process.env.PUBLIC_URL ? process.env.PUBLIC_URL : 'http://localhost:3000'
2020-12-07 01:31:48 +01:00
})
],
2020-12-07 01:31:48 +01:00
devServer: {
contentBase: path.join(__dirname, 'dist'),
compress: true,
port: 3000,
2020-12-09 04:44:12 +01:00
hot: true,
historyApiFallback: {
rewrites: [
{ from: /^\/c\//, to: '/index.html' }
]
}
2020-12-07 01:31:48 +01:00
}
}