Skip to content

Commit 06b627b

Browse files
committed
replace gulp with webpack, add prettier, eslint, improve build process
1 parent a8130c7 commit 06b627b

5 files changed

+98
-0
lines changed

.eslintignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
dist/
2+
*.zip

.eslintrc.json

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"extends": ["standard", "plugin:prettier/recommended"],
3+
"rules": {
4+
"promise/param-names": "off",
5+
"handle-callback-err": 0
6+
},
7+
"env": {
8+
"browser": true,
9+
"node": true,
10+
"jest": true
11+
}
12+
}

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
*zip*
2+
dist/
23
node_modules/
34
*.log
45
.idea

.prettierrc

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"semi": true,
3+
"printWidth": 120,
4+
"tabWidth": 2,
5+
"useTabs": false,
6+
"singleQuote": true,
7+
"bracketSpacing": true
8+
}

webpack.config.js

+75
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
const webpack = require('webpack');
2+
const CopyPlugin = require('copy-webpack-plugin');
3+
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
4+
const ZipFilesPlugin = require('webpack-zip-files-plugin');
5+
6+
const path = require('path');
7+
const packageFile = require('./package.json');
8+
9+
const libraryName = 'enhanced-github';
10+
const libVersion = packageFile.version;
11+
const license = packageFile.license;
12+
const destination = path.resolve(__dirname, 'dist');
13+
const zipDestination = path.resolve(__dirname, 'enhanced-github');
14+
15+
let deps = '';
16+
Object.keys(packageFile.dependencies).map((key, index) => {
17+
deps += `\n ${index + 1}. ${key} - ${packageFile.dependencies[key]}`;
18+
});
19+
20+
const libraryHeaderComment = `${libraryName} - v${libVersion}\n
21+
URL - https://github.com/softvar/ehanced-github\n
22+
${license} License, Copyright Varun Malhotra
23+
24+
Dependencies used - ${deps}`;
25+
26+
const plugins = [
27+
new webpack.BannerPlugin({
28+
banner: libraryHeaderComment,
29+
entryOnly: true
30+
}),
31+
new CleanWebpackPlugin({
32+
default: [destination]
33+
}),
34+
new CopyPlugin([
35+
{ from: 'options.js', to: destination },
36+
{ from: 'popup.js', to: destination },
37+
{ from: '*html', to: destination },
38+
{ from: 'manifest.json', to: destination },
39+
{ from: 'icons/*.png', to: destination }
40+
]),
41+
new ZipFilesPlugin({
42+
entries: [
43+
{ src: destination, dist: zipDestination }
44+
],
45+
output: zipDestination,
46+
format: 'zip',
47+
}),
48+
];
49+
50+
module.exports = function(_env, argv) {
51+
return {
52+
entry: {
53+
[libraryName]: './src/inject.js'
54+
},
55+
mode: argv.mode,
56+
output: {
57+
path: destination,
58+
filename: 'src/inject.js',
59+
library: libraryName,
60+
libraryTarget: 'global'
61+
},
62+
module: {
63+
rules: [
64+
{
65+
test: /\.js$/,
66+
exclude: /node_modules|dist/,
67+
use: {
68+
loader: 'babel-loader'
69+
}
70+
}
71+
]
72+
},
73+
plugins
74+
};
75+
};

0 commit comments

Comments
 (0)