You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

68 lines
1.4 KiB

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],
})
);
}