redux-devtools/extension/webpack/base.config.js

95 lines
2.3 KiB
JavaScript
Raw Normal View History

import path from 'path';
import webpack from 'webpack';
import CopyPlugin from 'copy-webpack-plugin';
2021-08-30 07:54:35 +03:00
import ForkTsCheckerWebpackPlugin from 'fork-ts-checker-webpack-plugin';
const extpath = path.join(__dirname, '../src/browser/extension/');
const mock = `${extpath}chromeAPIMock`;
const baseConfig = (params) => ({
// devtool: 'source-map',
mode: params.mode,
entry: params.input || {
background: [mock, `${extpath}background/index`],
options: [mock, `${extpath}options/index`],
window: [`${extpath}window/index`],
remote: [`${extpath}window/remote`],
devpanel: [mock, `${extpath}devpanel/index`],
devtools: [`${extpath}devtools/index`],
content: [mock, `${extpath}inject/contentScript`],
pagewrap: [`${extpath}inject/pageScriptWrap`],
...params.inputExtra,
},
output: {
filename: '[name].bundle.js',
chunkFilename: '[id].chunk.js',
...params.output,
},
plugins: [
new webpack.DefinePlugin(params.globals),
2021-08-30 07:54:35 +03:00
...(params.plugins
? params.plugins
: [
new ForkTsCheckerWebpackPlugin({
typescript: {
configFile: 'tsconfig.json',
},
}),
]),
].concat(
params.copy
? new CopyPlugin({
patterns: [
{
2020-11-17 04:20:57 +03:00
from: params.manifestJsonPath,
to: path.join(params.output.path, 'manifest.json'),
},
{
from: path.join(__dirname, '../src/assets/'),
to: params.output.path,
},
],
})
: []
),
optimization: {
2021-05-05 21:17:31 +03:00
minimize: false,
},
performance: {
hints: false,
},
resolve: {
alias: {
app: path.join(__dirname, '../src/app'),
tmp: path.join(__dirname, '../build/tmp'),
},
extensions: ['.js', '.jsx', '.ts', '.tsx'],
fallback: {
path: require.resolve('path-browserify'),
},
},
module: {
rules: [
...(params.loaders
? params.loaders
: [
{
test: /\.(js|ts)x?$/,
use: 'babel-loader',
exclude: /(node_modules|tmp\/page\.bundle)/,
},
]),
{
test: /\.css?$/,
use: ['style-loader', 'css-loader'],
},
{
test: /\.pug$/,
use: ['file-loader?name=[name].html', 'pug-html-loader'],
},
],
},
});
export default baseConfig;