redux-devtools/extension/webpack/base.config.js
Nathan Bierema 6cc517d97e
Refactor extension directory structure (#1248)
* Move background to top-level

* Move devpanel to top-level

* Move devtools to top-level

* Move options to top-level

* Move window to top-level

* Move chromeApiMock to top-level

* Move manifests to top-level

* Move contentScript to top-level

* Move pageScript to top-level

* Update tests

* Update Webpack config

* Fix path
2022-10-10 13:05:28 -04:00

101 lines
2.6 KiB
JavaScript

import path from 'path';
import webpack from 'webpack';
import CopyPlugin from 'copy-webpack-plugin';
import ForkTsCheckerWebpackPlugin from 'fork-ts-checker-webpack-plugin';
const baseConfig = (params) => ({
// devtool: 'source-map',
mode: params.mode,
entry: params.input || {
background: [
path.resolve(__dirname, '../src/chromeApiMock'),
path.resolve(__dirname, '../src/background/index'),
],
options: [
path.resolve(__dirname, '../src/chromeApiMock'),
path.resolve(__dirname, '../src/options/index'),
],
window: [path.resolve(__dirname, '../src/window/index')],
remote: [path.resolve(__dirname, '../src/remote/index')],
devpanel: [
path.resolve(__dirname, '../src/chromeApiMock'),
path.resolve(__dirname, '../src/devpanel/index'),
],
devtools: [path.resolve(__dirname, '../src/devtools/index')],
content: [
path.resolve(__dirname, '../src/chromeApiMock'),
path.resolve(__dirname, '../src/contentScript/index'),
],
pagewrap: [path.resolve(__dirname, '../src/pageScriptWrap')],
...params.inputExtra,
},
output: {
filename: '[name].bundle.js',
chunkFilename: '[id].chunk.js',
...params.output,
},
plugins: [
new webpack.DefinePlugin(params.globals),
...(params.plugins
? params.plugins
: [
new ForkTsCheckerWebpackPlugin({
typescript: {
configFile: 'tsconfig.json',
},
}),
]),
].concat(
params.copy
? new CopyPlugin({
patterns: [
{
from: params.manifestJsonPath,
to: path.join(params.output.path, 'manifest.json'),
},
{
from: path.join(__dirname, '../src/assets/'),
to: params.output.path,
},
],
})
: []
),
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;