redux-devtools/packages/redux-devtools-app/webpack.config.ts
renovate[bot] 6660eaae18
chore(deps): update dependency webpack to v5 (#788)
* chore(deps): update dependency webpack to v5

* Add path

* changes

* Add path to extension

* Fix things

* Fix that

Co-authored-by: Renovate Bot <bot@renovateapp.com>
Co-authored-by: Nathan Bierema <nbierema@gmail.com>
2021-08-29 04:09:37 +00:00

92 lines
2.1 KiB
TypeScript

import * as path from 'path';
import * as webpack from 'webpack';
import HtmlWebpackPlugin from 'html-webpack-plugin';
import ForkTsCheckerWebpackPlugin from 'fork-ts-checker-webpack-plugin';
module.exports = (env: { development?: boolean; platform?: string } = {}) => ({
mode: env.development ? 'development' : 'production',
entry: {
app: './demo/index',
},
output: {
path: path.resolve(__dirname, `build/${env.platform as string}`),
publicPath: '',
filename: 'js/[name].js',
sourceMapFilename: 'js/[name].map',
},
module: {
rules: [
{
test: /\.(js|ts)x?$/,
loader: 'babel-loader',
exclude: /node_modules/,
},
{
test: /\.html$/,
loader: 'html-loader',
},
{
test: /\.css$/,
use: [{ loader: 'style-loader' }, { loader: 'css-loader' }],
},
{
test: /\.(png|gif|jpg)$/,
loader: 'url-loader',
options: {
limit: '25000',
outputPath: 'images/',
publicPath: 'images/',
},
},
{
test: /\.(ttf|eot|svg|woff|woff2)$/,
loader: 'file-loader',
options: { outputPath: 'fonts/', publicPath: 'fonts/' },
},
],
},
resolve: {
extensions: ['.js', '.jsx', '.ts', '.tsx'],
fallback: {
path: require.resolve('path-browserify'),
},
},
plugins: [
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify(
env.development ? 'development' : 'production'
),
PLATFORM: JSON.stringify(env.platform),
},
}),
new HtmlWebpackPlugin({
template: 'assets/index.html',
}),
new ForkTsCheckerWebpackPlugin({
typescript: {
configFile: 'tsconfig.json',
},
}),
],
optimization: {
minimize: false,
splitChunks: {
cacheGroups: {
vendor: {
test: /[\\/]node_modules[\\/]/,
name: 'common',
chunks: 'all',
},
},
},
},
performance: {
hints: false,
},
devServer: {
port: 3000,
},
devtool: env.development ? 'eval-source-map' : 'source-map',
});