mirror of
https://github.com/mdn/webextensions-examples.git
synced 2026-04-16 06:18:35 +02:00
* new example: image-reference-collector (indexedDB file storage demo) * fix: added missing deps, updated all npm dependencies and webpack config to v.2 * chore: Renamed the example to store-collected-images * chore: Removed from utils/image-store any direct call to the UI code * move example built using webpack into its own subdir * tweak browser action title * added plain webextension example (without webpack build step) * added README.md file to plain webextension example * small changed based on the review comments * fixed typo in store-collected-images example (webpack-based version) * Remove React from the store-collected-images (plain webextension version) * Fix eslint errors on store-collected-images example (both versions) * Fix some typos in the README files
53 lines
1.5 KiB
JavaScript
53 lines
1.5 KiB
JavaScript
/* eslint-env node */
|
|
|
|
const path = require('path');
|
|
const webpack = require('webpack');
|
|
|
|
module.exports = {
|
|
entry: {
|
|
// Each entry in here would declare a file that needs to be transpiled
|
|
// and included in the extension source.
|
|
// For example, you could add a background script like:
|
|
background: 'background.js',
|
|
popup: 'popup.js',
|
|
'navigate-collection': 'navigate-collection.js',
|
|
},
|
|
output: {
|
|
// This copies each source entry into the extension dist folder named
|
|
// after its entry config key.
|
|
path: path.join(__dirname, 'extension', 'dist'),
|
|
filename: '[name].js',
|
|
},
|
|
module: {
|
|
rules: [{
|
|
exclude: ['/node_modules/', '!/node_modules/idb-file-storage'],
|
|
test: /\.js$/,
|
|
use: [
|
|
// This transpiles all code (except for third party modules) using Babel.
|
|
{
|
|
// Babel options are in .babelrc
|
|
loader: 'babel-loader',
|
|
},
|
|
]
|
|
}]
|
|
},
|
|
resolve: {
|
|
// This allows you to import modules just like you would in a NodeJS app.
|
|
extensions: ['.js', '.jsx'],
|
|
modules: [
|
|
path.join(__dirname, 'src'),
|
|
'node_modules',
|
|
],
|
|
},
|
|
plugins: [
|
|
// Since some NodeJS modules expect to be running in Node, it is helpful
|
|
// to set this environment var to avoid reference errors.
|
|
new webpack.DefinePlugin({
|
|
'process.env.NODE_ENV': JSON.stringify('production'),
|
|
}),
|
|
],
|
|
// This will expose source map files so that errors will point to your
|
|
// original source files instead of the transpiled files.
|
|
devtool: 'sourcemap',
|
|
};
|