You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
constpath=require('path');module.exports={mode: 'production',entry: './src/index.js',// This will output a single file under `dist/bundle.js`output: {filename: 'bundle.js',path: path.resolve(__dirname,'dist'),}}
try{// This is the file produced by webpackimportScripts('dist/bundle.js');}catch(e){// This will allow you to see error logs during registration/executionconsole.error(e);}
Hey, thanks for this.
I was trying to access firestore db in my v3 chrome extension. Following the steps you mentioned, I imported firebase/app and firebase/firestore in index.js -> bundle it up -> import bundle.js in my extension's background file.
Here is what inside index.js:
import { initializeApp } from "firebase/app"
import { getFirestore, collection, query, where, getDocs, addDoc } from "firebase/firestore"
const firebaseApp = initializeApp({
....
});
const db = getFirestore();
I'm trying to access db from background.js but I have no idea how to call it by looking at the code in bundle.js
Any idea?
@noovil hey just noticed your comment, but it looks like you were able to figure things out on your own. Hope you still found the guide a useful starting point!
Working on my amazing, incredible, life-changing Chrome extension, I noticed there wasn't much documentation available in terms of how to use manifest v3 extensions in conjunction with Webpack to modularize code. So here's a pretty quick guide.
(you can also just skip to the GitHub repository if you're into that sort of thing)
Write your code:
src/index.js
src/example.js
Setup your webpack.config.js file and run webpack:
webpack.config.js
Create your service worker entrypoint, importing the produced bundle:
service-worker.js
Reference the file in your manifest:
manifest.json
Load your unpacked extension and inspect the service worker view to check the output:
Done.
The text was updated successfully, but these errors were encountered: