redux-devtools/packages/redux-devtools-app/webpack.config.ts

92 lines
2.1 KiB
TypeScript
Raw Normal View History

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