Skip to content

Commit 814603b

Browse files
committed
initi commit
1 parent 17328f1 commit 814603b

25 files changed

+32884
-0
lines changed

.gitignore

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
8+
# Runtime data
9+
pids
10+
*.pid
11+
*.seed
12+
*.pid.lock
13+
14+
# Directory for instrumented libs generated by jscoverage/JSCover
15+
lib-cov
16+
17+
# Coverage directory used by tools like istanbul
18+
coverage
19+
20+
# nyc test coverage
21+
.nyc_output
22+
23+
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
24+
.grunt
25+
26+
# Bower dependency directory (https://bower.io/)
27+
bower_components
28+
29+
# node-waf configuration
30+
.lock-wscript
31+
32+
# Compiled binary addons (http://nodejs.org/api/addons.html)
33+
build/Release
34+
35+
# Dependency directories
36+
node_modules/
37+
jspm_packages/
38+
39+
# Typescript v1 declaration files
40+
typings/
41+
42+
# Optional npm cache directory
43+
.npm
44+
45+
# Optional eslint cache
46+
.eslintcache
47+
48+
# Optional REPL history
49+
.node_repl_history
50+
51+
# Output of 'npm pack'
52+
*.tgz
53+
54+
# Yarn Integrity file
55+
.yarn-integrity
56+
57+
# dotenv environment variables file
58+
.env
59+
60+
.local-files/
61+
.trash/
62+

app-factory.js

+101
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
const webpack = require('webpack');
2+
const HtmlWebpackPlugin = require('html-webpack-plugin');
3+
process.env.NODE_ENV = "development";
4+
const CopyPlugin = require("copy-webpack-plugin");
5+
const { join } = require("path");
6+
7+
8+
function getCompilerConfig() {
9+
const config = {
10+
optimization: {
11+
minimize: false,
12+
},
13+
entry: {
14+
options: join(__dirname, "ui/options.js"),
15+
agent: join(__dirname, "src/agent.js"),
16+
background: join(__dirname, "src/background.js"),
17+
},
18+
output: {
19+
filename: '[name].js',
20+
path: join(__dirname, "chrome-extension"),
21+
chunkFilename: '[name].bundle.js',
22+
},
23+
module: {
24+
rules: [
25+
{
26+
test: /\.(js|jsx)$/,
27+
exclude: /node_modules/,
28+
use: {
29+
loader: 'babel-loader',
30+
options: {
31+
"sourceType": "unambiguous",
32+
plugins: [
33+
"@babel/plugin-proposal-class-properties",
34+
"@babel/plugin-transform-react-jsx",
35+
]
36+
}
37+
}
38+
},
39+
{
40+
test: /\.scss$/,
41+
use: [
42+
{
43+
loader: "style-loader" // creates style nodes from JS strings
44+
},
45+
{
46+
loader: "css-loader" // translates CSS into CommonJS
47+
},
48+
{
49+
loader: "sass-loader" // compiles Sass to CSS
50+
}
51+
]
52+
}
53+
]
54+
},
55+
resolve: {
56+
extensions: ['*', '.js', '.jsx']
57+
},
58+
devtool: 'inline-source-map',
59+
// devServer: {
60+
// contentBase: './dist',
61+
// hot: true,
62+
// },
63+
plugins: [
64+
65+
new HtmlWebpackPlugin({
66+
chunks: ["options"],
67+
template: "ui/options.ejs",
68+
filename: 'options.html'
69+
}),
70+
new CopyPlugin({
71+
patterns: [
72+
{ from: "src/manifest.json" }
73+
],
74+
}),
75+
new webpack.SourceMapDevToolPlugin({})
76+
]
77+
}
78+
return config
79+
}
80+
81+
82+
const compilerDone = (err, stats) => {
83+
const { errors, missingDependencies } = stats.compilation;
84+
if (errors.length) {
85+
return errors.forEach(error => console.log(`got an error when compiling: ${error.message}`, error.stack))
86+
}
87+
console.log(`app build ${stats.hash} completed`)
88+
}
89+
90+
module.exports = (watch) => {
91+
const compiler = webpack(getCompilerConfig());
92+
if (watch) {
93+
console.log("In dev mode. Starting watcher")
94+
compiler.watch({
95+
aggregateTimeout: 300,
96+
poll: undefined
97+
}, compilerDone)
98+
} else {
99+
compiler.run(compilerDone)
100+
}
101+
}

0 commit comments

Comments
 (0)