const path = require('path');
|
|
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
|
const CopyWebpackPlugin = require('copy-webpack-plugin');
|
|
|
|
module.exports = {
|
|
entry: {
|
|
index: './src/index.tsx',
|
|
background: './src/background.ts',
|
|
contentScript: './src/contentScript.ts'
|
|
},
|
|
module: {
|
|
rules: [
|
|
{
|
|
test: /\.tsx?$/,
|
|
use: 'ts-loader',
|
|
exclude: /node_modules/
|
|
},
|
|
{
|
|
test: /\.js$/,
|
|
use: 'babel-loader',
|
|
exclude: /node_modules/
|
|
},
|
|
{
|
|
test: /\.css$/,
|
|
use: ['style-loader', 'css-loader']
|
|
},
|
|
{
|
|
test: /\.(png|jpe?g|gif)$/i,
|
|
use: [
|
|
{
|
|
loader: 'file-loader',
|
|
options: {
|
|
outputPath: 'images',
|
|
name: '[name].[ext]',
|
|
},
|
|
},
|
|
],
|
|
},
|
|
]
|
|
},
|
|
resolve: {
|
|
extensions: ['.tsx', '.ts', '.js']
|
|
},
|
|
plugins: [
|
|
new CopyWebpackPlugin({
|
|
patterns: [
|
|
{ from: "manifest.json", to: "../manifest.json" },
|
|
{ from: "icons", to: "../icons"}
|
|
],
|
|
}),
|
|
...getHtmlPlugins(["index"]),
|
|
],
|
|
output: {
|
|
path: path.join(__dirname, "dist/js"),
|
|
filename: "[name].js",
|
|
},
|
|
};
|
|
|
|
function getHtmlPlugins(chunks) {
|
|
return chunks.map(
|
|
(chunk) =>
|
|
new HtmlWebpackPlugin({
|
|
title: "React extension",
|
|
filename: `${chunk}.html`,
|
|
chunks: [chunk],
|
|
})
|
|
);
|
|
}
|