Skip to content

Instantly share code, notes, and snippets.

@varaprasadh
Created June 3, 2021 12:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save varaprasadh/273cf497ffb82a97bbd0583ee9b36fcc to your computer and use it in GitHub Desktop.
Save varaprasadh/273cf497ffb82a97bbd0583ee9b36fcc to your computer and use it in GitHub Desktop.
const HtmlWebpackPlugin = require('html-webpack-plugin');
const { CleanWebpackPlugin } = require('clean-webpack-plugin')
const copyWebpackPlugin = require('copy-webpack-plugin')
const { resolve } = require('path');
const plugins = [
new HtmlWebpackPlugin({
template: './public/new-tab.raw.html',
filename:'new-tab.html',
chunks:['newTab']
}),
new copyWebpackPlugin({
patterns:[
{
from: 'public', to: '.', filter:str=>!/\.raw.html$/.test(str)
}
]
}),
new CleanWebpackPlugin()
];
module.exports = {
mode:'production',
devtool: 'cheap-module-source-map',
entry:{
newTab: './src/newTab/newTab.tsx',
background: './src/background.ts'
},
output:{
filename:'[name].js',
path: resolve(__dirname,'dist')
},
resolve: {
extensions: ['.ts', '.tsx', '.js']
},
module:{
rules:[
{
test:/\.ts(x?)$/,
exclude:/node_modules/,
use: 'ts-loader'
},
{
test:/\.css$/,
use: ['style-loader','css-loader']
},
{
test: /\.(png|jpe?g|gif)$/i,
use: {
loader: 'file-loader',
options: {
name: 'images/[name].[ext]'
}
}
},
]
},
plugins
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment