Skip to content

Commit

Permalink
init: add chrome-plugin-starter
Browse files Browse the repository at this point in the history
一个简单的chrome插件
  • Loading branch information
feint123 committed Jun 18, 2024
1 parent 11893d8 commit 4805f15
Show file tree
Hide file tree
Showing 19 changed files with 4,426 additions and 0 deletions.
10 changes: 10 additions & 0 deletions chrome-plugin-starter/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# dependencies
/node_modules

# production
/build

# misc
.DS_Store

npm-debug.log*
21 changes: 21 additions & 0 deletions chrome-plugin-starter/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# <img src="public/icons/icon_48.png" width="45" align="left"> Chrome Plugin Starter

My Chrome Extension

## Features

- Feature 1
- Feature 2

## Install

[**Chrome** extension]()

## Contribution

Suggestions and pull requests are welcomed!.

---

This project was bootstrapped with [Chrome Extension CLI](https://github.com/dutiyesh/chrome-extension-cli)

10 changes: 10 additions & 0 deletions chrome-plugin-starter/config/paths.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
'use strict';

const path = require('path');

const PATHS = {
src: path.resolve(__dirname, '../src'),
build: path.resolve(__dirname, '../build'),
};

module.exports = PATHS;
67 changes: 67 additions & 0 deletions chrome-plugin-starter/config/webpack.common.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
'use strict';

const SizePlugin = require('size-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');

const PATHS = require('./paths');

// To re-use webpack configuration across templates,
// CLI maintains a common webpack configuration file - `webpack.common.js`.
// Whenever user creates an extension, CLI adds `webpack.common.js` file
// in template's `config` folder
const common = {
output: {
// the build folder to output bundles and assets in.
path: PATHS.build,
// the filename template for entry chunks
filename: '[name].js',
},
devtool: 'source-map',
stats: {
all: false,
errors: true,
builtAt: true,
},
module: {
rules: [
// Help webpack in understanding CSS files imported in .js files
{
test: /\.css$/,
use: [MiniCssExtractPlugin.loader, 'css-loader'],
},
// Check for images imported in .js files and
{
test: /\.(png|jpe?g|gif)$/i,
use: [
{
loader: 'file-loader',
options: {
outputPath: 'images',
name: '[name].[ext]',
},
},
],
},
],
},
plugins: [
// Print file sizes
new SizePlugin(),
// Copy static assets from `public` folder to `build` folder
new CopyWebpackPlugin({
patterns: [
{
from: '**/*',
context: 'public',
},
]
}),
// Extract CSS into separate files
new MiniCssExtractPlugin({
filename: '[name].css',
}),
],
};

module.exports = common;
17 changes: 17 additions & 0 deletions chrome-plugin-starter/config/webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
'use strict';

const { merge } = require('webpack-merge');

const common = require('./webpack.common.js');
const PATHS = require('./paths');

// Merge webpack configuration files
const config = merge(common, {
entry: {
popup: PATHS.src + '/popup.js',
contentScript: PATHS.src + '/contentScript.js',
background: PATHS.src + '/background.js',
},
});

module.exports = config;
Loading

0 comments on commit 4805f15

Please sign in to comment.