mirror of
https://github.com/abhijithvijayan/web-extension-starter.git
synced 2025-10-07 07:22:37 +02:00
83 lines
2.3 KiB
JavaScript
83 lines
2.3 KiB
JavaScript
const path = require('path');
|
|
const webpack = require('webpack');
|
|
const CopyWebpackPlugin = require('copy-webpack-plugin');
|
|
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
|
const FixStyleOnlyEntriesPlugin = require('webpack-fix-style-only-entries');
|
|
|
|
module.exports = {
|
|
mode: 'development',
|
|
|
|
entry: {
|
|
background: './src/scripts/background.js',
|
|
popup: './src/scripts/popup.js',
|
|
options: './src/scripts/options.js',
|
|
styles: ['./src/styles/popup.scss', './src/styles/options.scss'],
|
|
},
|
|
|
|
output: {
|
|
filename: 'js/[name].[chunkhash].js',
|
|
path: path.resolve(__dirname, 'extension', process.env.TARGET),
|
|
},
|
|
|
|
plugins: [
|
|
new FixStyleOnlyEntriesPlugin(),
|
|
new CopyWebpackPlugin([
|
|
{ from: 'src/assets', to: 'assets' },
|
|
{ from: `src/manifests/${process.env.TARGET}.json`, to: 'manifest.json' },
|
|
]),
|
|
new webpack.ProgressPlugin(),
|
|
new HtmlWebpackPlugin(),
|
|
],
|
|
|
|
module: {
|
|
rules: [
|
|
{
|
|
test: /.(js|jsx)$/,
|
|
include: [path.resolve(__dirname, 'src/scripts')],
|
|
loader: 'babel-loader',
|
|
|
|
options: {
|
|
plugins: ['syntax-dynamic-import'],
|
|
|
|
presets: [
|
|
[
|
|
'@babel/preset-env',
|
|
{
|
|
modules: false,
|
|
},
|
|
],
|
|
],
|
|
},
|
|
},
|
|
{
|
|
test: /\.scss$/,
|
|
use: [
|
|
{
|
|
loader: 'file-loader',
|
|
options: {
|
|
name: '[name].css',
|
|
context: './src/styles/',
|
|
outputPath: 'css/',
|
|
},
|
|
},
|
|
'extract-loader',
|
|
{
|
|
loader: 'css-loader',
|
|
options: {
|
|
sourceMap: true,
|
|
},
|
|
},
|
|
'resolve-url-loader',
|
|
'sass-loader',
|
|
],
|
|
},
|
|
],
|
|
},
|
|
|
|
optimization: {},
|
|
|
|
devServer: {
|
|
open: true,
|
|
},
|
|
};
|