mirror of
https://gitlab.com/KevinRoebert/ClearUrls
synced 2025-12-17 06:35:37 +07:00
init
This commit is contained in:
82
webpack.config.js
Normal file
82
webpack.config.js
Normal file
@@ -0,0 +1,82 @@
|
||||
const path = require('path')
|
||||
const SizePlugin = require('size-plugin')
|
||||
const CopyWebpackPlugin = require('copy-webpack-plugin')
|
||||
const TerserPlugin = require('terser-webpack-plugin')
|
||||
|
||||
module.exports = {
|
||||
devtool: 'source-map',
|
||||
stats: 'errors-only',
|
||||
entry: {
|
||||
// target_path/target_file_name: full_source_path
|
||||
'background/main': './source/background/main.ts',
|
||||
},
|
||||
output: {
|
||||
path: path.join(__dirname, 'distribution'),
|
||||
filename: '[name].js',
|
||||
},
|
||||
resolve: {
|
||||
// Add '.ts' and '.tsx' as a resolvable extension.
|
||||
extensions: ['.webpack.js', '.web.js', '.ts', '.tsx', '.js', '.json'],
|
||||
alias: {
|
||||
'webextension-polyfill-ts': path.resolve(
|
||||
path.join(__dirname, 'node_modules', 'webextension-polyfill-ts'),
|
||||
),
|
||||
},
|
||||
},
|
||||
module: {
|
||||
rules: [
|
||||
// all files with a '.ts' or '.tsx' extension will be handled by 'ts-loader'
|
||||
{
|
||||
test: /\.tsx?$/,
|
||||
loader: 'ts-loader',
|
||||
options: {
|
||||
configFile: 'tsconfig.json',
|
||||
},
|
||||
exclude: /node_modules/,
|
||||
},
|
||||
{
|
||||
test: /\.s[ac]ss$/i,
|
||||
use: [
|
||||
{
|
||||
loader: 'file-loader',
|
||||
options: {
|
||||
name(resourcePath, resourceQuery) {
|
||||
return resourcePath.replace(/.+source[\/\\]/, '').replace(/\.s[ac]ss$/i, '.css')
|
||||
},
|
||||
},
|
||||
},
|
||||
// Compiles Sass to CSS
|
||||
'sass-loader',
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
plugins: [
|
||||
new SizePlugin(),
|
||||
new CopyWebpackPlugin({
|
||||
patterns: [
|
||||
{
|
||||
from: '**/*',
|
||||
context: 'source',
|
||||
globOptions: {
|
||||
ignore: ['**/*.js', '**/*.ts', '**/*.tsx', '**/*.scss'],
|
||||
},
|
||||
},
|
||||
],
|
||||
}),
|
||||
],
|
||||
optimization: {
|
||||
minimizer: [
|
||||
new TerserPlugin({
|
||||
terserOptions: {
|
||||
mangle: false,
|
||||
compress: false,
|
||||
output: {
|
||||
beautify: true,
|
||||
indent_level: 2, // eslint-disable-line camelcase
|
||||
},
|
||||
},
|
||||
}),
|
||||
],
|
||||
},
|
||||
}
|
||||
Reference in New Issue
Block a user