A quick introduction to the folders and files in this repo.
The source files which you will need to build the extension are present inside the src
folder. Run npm run chrome-launch
or npm run firefox-launch
to see the changes that you make inside your src
folder live in the browser.
The project uses Webpack to bundle the project into a folder like extension
in case of production build and dev
in case of development build. A lot of different webpack plugins are used for the webpack bundling process which can be seen inside the config/webpack/plugins.js
file.
A big thanks to the Memex
project for helping in setting up the boilerplate code and to Facebook's create-react-app
for helping in setup the webpack config.
Source Organisation: src/
To keep things modular, the resources are divided into folders namely /background
, /content_scripts
, /options
, /popup
and /sidebar
and manifest.json
. We can obviously introduce more as required.
-
/lib
: Contains JS and CSS libraries which are not to be compiled and minified by webpack.The
/lib
folder is copied as it is to the build folder which isextension
during production build anddev
during development build. If you have vendor libraries like bootstrap.css, you can put it inside the lib folder. This comes handy when you have to usedchrome.tabs.executeScript()
, the script to be injected can be placed here. -
background
: Contains scripts relating to the extension background page. -
content_scripts
: Contains scripts relating to the extension content_scripts page.Webpack bundles the
index.js
intocontent_scripts.js
in the build folder. -
popup
: Contains scripts relating to the extension popup page.Webpack bundles the
index.js
intopopup.js
in the build folder which is referenced inside thepopup.html
.index.js
: Main file which webpack looks for while bundling. All others scripts for popup are refreneced here.template.html
- Provides the base for popup.html. All scripts and CSS file tags are added dynamically using Webpack at compile time.
-
options
: Contains scripts relating to the extension options page.Webpack bundles the
index.js
intooptions.js
in the build folder which is referenced inside theoptions.html
.index.js
: Main file which webpack looks for while bundling. All others scripts for options are refreneced here.template.html
- Provides the base for options.html. All scripts and CSS file tags are added dynamically using Webpack at compile time.
-
fonts
: Contains CSS files for fonts used in the extension. -
images
: Contains images used in the extension
webpack/
: Contains the webpack config file and all the files necessary for setting up the webpack config.env.js
: Loads environment variables from.env
. Reference taken from https://github.com/facebook/create-react-app/blob/master/packages/react-scripts/config/env.jspaths.js
: Returns an API that provides absolute paths for different files inside this project . Reference taken from https://github.com/facebook/create-react-app/blob/master/packages/react-scripts/config/paths.js
-
package.json
- Contains project dependencies, info about project and run commands. -
package-lock.json
: npm config file (genertaed alongwith package.json). This shouldn't be modified unless you're adding new dependencies or updating them. -
.eslintrc.js
: ESLint config file -
.eslintignore
: Files to be ignored by ESLint. -
.babelrc
: Babel config file. -
.storybook
: Config to setup storybook.
.gitignore
: Contains a list of files and folders to be ignored by git. More about gitignore..LICENSE
: license file. A software license tells others what they can and can't do with your source code. The most common licenses for open source projects are MIT, Apache, GNU... licenses. The license used in this project is the MIT license.
-
README.md
: Introduction to this project along with instructions to build and contribute to this project. -
CONTRIBUTING.md
: Deatiled instructions on contributing to this project. -
CODETOUR.md
: A tour through all the files and folders of this project.
Please feel free to make changes to the above documentation :)