npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

webpack-chrome-extension-dev-template

v0.2.2

Published

[简体中文](https://github.com/HuPeng333/webpack-chrome-extension-dev-template/blob/master/README.md)

Downloads

2

Readme

webpack-chrome-extension-dev-template

简体中文

Github

based on webpack, allow you to build Chrome Extension with EsModules, and auto generate manifest.json for you

Install

It is not a dependence but template! So you can't download it with npm install!

Install with npx (Recommend)

npx webpack-chrome-extension-dev-cli ${project_name}

Download template from GitHub RELEASE

RELEASE

Download from GitHub may not be a new version! If you really want to download from GitHub, I recommend you clone the code to get the new version!


Docs

How to build the extension

Project Structure

-| src
    ---|content-script
        ---|module1
            ---|index.js  // 'content-script' entry, build your extension here
        ---|module2
            ---|index.js  // 'content-script' entry, build your extension here
        // ... 
        
    ---|public // the file in this folder will be intact moved to the output path, you can put your js lib here
    
    ---|popup // the file in this folder will be intact moved to the output path
        ---|index.html // start build your popup here, the 'manifest.json' will auto point to it
        
    ---|options // the file in this folder will be intact moved to the output path
        ---|index.html // start build your config page here, the 'manifest.json' will auto point to it
        
    ---|background
        ---|index.js // build `service workers` here, you can use EsModules!
        
-|manifestConfig.json // add additional 'manifest.json' config here
-|webpack-config.js // config the webpack, see 'Config the webpack.config.js' below

please strictly follow the template structure! It will help to generate 'manifest.json'

you can create multi modules(folder) in the content-script folder! But the entrance file name must be index.js, about how to config the matches property in content-script, see Config the manifest.json

You can import css file in content-script modules!

Run

Run in development mode, it could auto hot update,but you may reload the extension in the browser! To solve this problem, see Browser hot update

npm run dev

Run in 'production' mode

npm run build

The resources will be generated in dist folder, you can use your browser to load it!

Config

But you can't modify the content_scripts! If you want to modify the matches field, please instead with content_scripts_matches

{
  "content_scripts_matches": {
    "moduleName": [
      "https://*.github.com"
    ],
    "moduleName2": [
      "<all_urls>"
    ]
  }
}

please make sure the ``content_scripts_matchesfield name matches the module name incontent-script` folder!

If you don't provide it, it will use <all_urls> by default.

Config the webpack.config.js

The webpack config file is hidden, but sometimes we want to add additional support(like TypeScript)

First, you should create a webpack-config.js file in the root path, it is not webpack.config.js!

You can config or modify the webpack config here

module.exports = (webpackConfig) => {
  
  // modify 'webpackConfig' object here
  
  return webpackConfig
}

Please mark sure you return the webpackConfig object!

Although in development mode, we can hot update the extension, but the browser couldn't reload our newly extension!

In this situation, you have to reload the extension in your browser 'extension' page.

To solve this problem, you can add this code in background(in src/background/index.js)

import {launchHotUpdate} from 'webpack-chrome-extension-dev-script'

if (SCRIPT_MODE === 'development') {
  launchHotUpdate()
}

Now, you modify your code in dev mode, and then use f5 to refresh your browser, it will be auto reload!

The SCRIPT_MODE is smiler to process.env.NODE_ENV

Warn: don use process.env.NODE_ENV to judge build mode! Because the extension, which is build with development mode in webpack, can't run in browser! So the process.env.NODE_ENV always production!