Skip to content

Commit de319a9

Browse files
committed
initial commit
0 parents  commit de319a9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+78762
-0
lines changed

.babelrc

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"presets": [
3+
"@babel/preset-env",
4+
"@babel/preset-react"
5+
]
6+
}

.env

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
GENERATE_SOURCEMAP=false
2+
INLINE_RUNTIME_CHUNK=false

.eslintignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/dist
2+
/node_modules
3+
/dev
4+
/extension

.eslintrc.js

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
module.exports = {
2+
env: {
3+
browser: true,
4+
commonjs: true,
5+
es6: true,
6+
node: true,
7+
jest: true
8+
},
9+
extends: 'eslint:recommended',
10+
parser: 'babel-eslint',
11+
parserOptions: {
12+
sourceType: 'module',
13+
ecmaVersion: 2018,
14+
ecmaFeatures: {
15+
jsx: true,
16+
},
17+
},
18+
plugins: ['react'],
19+
rules: {
20+
"no-console": "off",
21+
"no-underscore-dangle": "off",
22+
"no-plusplus": "off",
23+
"no-continue": "off",
24+
"camelcase": "off",
25+
"no-empty": "off",
26+
"no-param-reassign": "off",
27+
"func-names": [
28+
"error",
29+
"never"
30+
],
31+
"prefer-destructuring": [
32+
"error",
33+
{
34+
"object": false,
35+
"array": false
36+
}
37+
],
38+
indent: ['error', 2, { SwitchCase: 1 }],
39+
'linebreak-style': ['error', 'unix'],
40+
quotes: ['error', 'single', { allowTemplateLiterals: true }],
41+
semi: ['error', 'always'],
42+
'react/jsx-uses-vars': 1,
43+
'react/jsx-uses-react': 1,
44+
'spaced-comment': ['error', 'always', { exceptions: ['-', '+'] }],
45+
},
46+
};

.gitignore

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
node_modules
2+
try.js
3+
old-extension
4+
dist
5+
extension
6+
.vscode

.storybook/config.js

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { configure } from '@storybook/react';
2+
3+
// automatically import all files ending in *.stories.js
4+
const req = require.context('../stories', true, /.stories.js$/);
5+
function loadStories() {
6+
req.keys().forEach(filename => req(filename));
7+
}
8+
9+
configure(loadStories, module);

LICENSE

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
MIT License
3+
4+
Copyright (c) 2019 Minanshu Singh
5+
6+
Permission is hereby granted, free of charge, to any person obtaining a copy
7+
of this software and associated documentation files (the "Software"), to deal
8+
in the Software without restriction, including without limitation the rights
9+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
copies of the Software, and to permit persons to whom the Software is
11+
furnished to do so, subject to the following conditions:
12+
13+
The above copyright notice and this permission notice shall be included in all
14+
copies or substantial portions of the Software.
15+
16+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
SOFTWARE.

README.md

+97
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
# React Extension Boilerlplate for Chrome and Firefox
2+
3+
<p align="center">
4+
<a href="https://travis-ci.org/kbrsh/moon"><img src="https://travis-ci.org/kbrsh/moon.svg?branch=master" alt="Build Status"></a>
5+
<a href="https://codecov.io/gh/kbrsh/moon"><img src="https://codecov.io/gh/kbrsh/moon/branch/master/graph/badge.svg" alt="Code Coverage"></a>
6+
<a href="https://moon-slack.herokuapp.com"><img src="https://moon-slack.herokuapp.com/badge.svg" alt="Slack"></a>
7+
<a href="https://github.com"><img src="https://img.shields.io/badge/license-MIT-blue.svg" alt="License"></a>
8+
</p>
9+
10+
HTML5 Boilerplate is a professional front-end template for building
11+
fast, robust, and adaptable web apps or sites.
12+
13+
This project is the product of years of iterative development and
14+
community knowledge. It does not impose a specific development
15+
philosophy or framework, so you're free to architect your code in the
16+
way that you want.
17+
18+
* Homepage: [https://html5boilerplate.com/](https://html5boilerplate.com/)
19+
* Source: [https://github.com/h5bp/html5-boilerplate](https://github.com/h5bp/html5-boilerplate)
20+
* Twitter: [@h5bp](https://twitter.com/h5bp)
21+
22+
23+
## Quick start
24+
25+
Choose one of the following options:
26+
27+
- Download the latest stable release from
28+
[html5boilerplate.com](https://html5boilerplate.com/).
29+
- Clone the git repo — `git clone
30+
https://github.com/h5bp/html5-boilerplate.git` - and checkout the
31+
[tagged release](https://github.com/h5bp/html5-boilerplate/releases)
32+
you'd like to use.
33+
- Install with [npm](https://www.npmjs.com/): `npm install html5-boilerplate` and pull in what you need from the resulting `node_modules/html5-boilerplate/dist`
34+
- Install with [yarn](https://yarnpkg.com/): `yarn add html5-boilerplate`
35+
36+
37+
## Features
38+
39+
* HTML5 ready. Use the new elements with confidence.
40+
* Designed with progressive enhancement in mind.
41+
* Includes:
42+
* [`Normalize.css`](https://necolas.github.com/normalize.css/)
43+
for CSS normalizations and common bug fixes
44+
* [`jQuery`](https://jquery.com/) via CDN with [SRI Hash](https://developer.mozilla.org/en-US/docs/Web/Security/Subresource_Integrity) and a local fallback
45+
* A custom build of [`Modernizr`](https://modernizr.com/) for feature
46+
detection
47+
* [`Apache Server Configs`](https://github.com/h5bp/server-configs-apache)
48+
that, among other, improve the web site's performance and security
49+
* Placeholder CSS Media Queries.
50+
* Useful CSS helper classes.
51+
* Default print styles, performance optimized.
52+
* An optimized version of the Google Universal Analytics snippet.
53+
* Protection against any stray `console` statements causing JavaScript
54+
errors in older browsers.
55+
* "Delete-key friendly." Easy to strip out parts you don't need.
56+
* Extensive inline and accompanying documentation.
57+
58+
59+
## Browser support
60+
61+
* Chrome *(latest 2)*
62+
* Edge *(latest 2)*
63+
* Firefox *(latest 2)*
64+
* Internet Explorer 9+
65+
* Opera *(latest 2)*
66+
* Safari *(latest 2)*
67+
68+
*This doesn't mean that HTML5 Boilerplate cannot be used in older browsers,
69+
just that we'll ensure compatibility with the ones mentioned above.*
70+
71+
If you need legacy browser support you
72+
can use [HTML5 Boilerplate v4](https://github.com/h5bp/html5-boilerplate/tree/v4) (IE 6+, Firefox 3.6+, Safari 4+),
73+
or [HTML5 Boilerplate v5](https://github.com/h5bp/html5-boilerplate/tree/v5.0.0) (IE8+). They are no longer actively developed.
74+
75+
76+
## Documentation
77+
78+
Take a look at the [documentation table of contents](dist/doc/TOC.md).
79+
This documentation is bundled with the project which makes it
80+
available for offline reading and provides a useful starting point for
81+
any documentation you want to write about your project.
82+
83+
84+
## Contributing
85+
86+
Hundreds of developers have helped to make the HTML5 Boilerplate. Anyone is welcome to [contribute](.github/CONTRIBUTING.md),
87+
however, if you decide to get involved, please take a moment to review
88+
the [guidelines](.github/CONTRIBUTING.md):
89+
90+
* [Bug reports](.github/CONTRIBUTING.md#bugs)
91+
* [Feature requests](.github/CONTRIBUTING.md#features)
92+
* [Pull requests](.github/CONTRIBUTING.md#pull-requests)
93+
94+
95+
## License
96+
97+
The code is available under the [MIT license](LICENSE.txt).

config/env.js

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
'use strict';
2+
3+
const fs = require('fs');
4+
const path = require('path');
5+
const paths = require('./paths');
6+
7+
// Make sure that including paths.js after env.js will read .env variables.
8+
delete require.cache[require.resolve('./paths')];
9+
10+
const NODE_ENV = process.env.NODE_ENV;
11+
if (!NODE_ENV) {
12+
throw new Error(
13+
'The NODE_ENV environment variable is required but was not specified.'
14+
);
15+
}
16+
17+
// https://github.com/bkeepers/dotenv#what-other-env-files-can-i-use
18+
var dotenvFiles = [
19+
`${paths.dotenv}.${NODE_ENV}.local`,
20+
`${paths.dotenv}.${NODE_ENV}`,
21+
// Don't include `.env.local` for `test` environment
22+
// since normally you expect tests to produce the same
23+
// results for everyone
24+
NODE_ENV !== 'test' && `${paths.dotenv}.local`,
25+
paths.dotenv,
26+
].filter(Boolean);
27+
28+
// Load environment variables from .env* files. Suppress warnings using silent
29+
// if this file is missing. dotenv will never modify any environment variables
30+
// that have already been set. Variable expansion is supported in .env files.
31+
// https://github.com/motdotla/dotenv
32+
// https://github.com/motdotla/dotenv-expand
33+
dotenvFiles.forEach(dotenvFile => {
34+
if (fs.existsSync(dotenvFile)) {
35+
require('dotenv-expand')(
36+
require('dotenv').config({
37+
path: dotenvFile,
38+
})
39+
);
40+
}
41+
});
42+
43+
// We support resolving modules according to `NODE_PATH`.
44+
// This lets you use absolute paths in imports inside large monorepos:
45+
// https://github.com/facebook/create-react-app/issues/253.
46+
// It works similar to `NODE_PATH` in Node itself:
47+
// https://nodejs.org/api/modules.html#modules_loading_from_the_global_folders
48+
// Note that unlike in Node, only *relative* paths from `NODE_PATH` are honored.
49+
// Otherwise, we risk importing Node.js core modules into an app instead of Webpack shims.
50+
// https://github.com/facebook/create-react-app/issues/1023#issuecomment-265344421
51+
// We also resolve them to make sure all tools using them work consistently.
52+
const appDirectory = fs.realpathSync(process.cwd());
53+
process.env.NODE_PATH = (process.env.NODE_PATH || '')
54+
.split(path.delimiter)
55+
.filter(folder => folder && !path.isAbsolute(folder))
56+
.map(folder => path.resolve(appDirectory, folder))
57+
.join(path.delimiter);

config/paths.js

+92
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
const path = require('path');
2+
const fs = require('fs');
3+
const url = require('url');
4+
5+
const appDirectory = fs.realpathSync(process.cwd());
6+
console.log('appDirectory: ', appDirectory);
7+
const resolveApp = relativePath => path.resolve(appDirectory, relativePath);
8+
console.log(resolveApp('.env'));
9+
10+
const envPublicUrl = process.env.PUBLIC_URL;
11+
12+
function ensureSlash(inputPath, needsSlash) {
13+
const hasSlash = inputPath.endsWith('/');
14+
if (hasSlash && !needsSlash) {
15+
return inputPath.substr(0, inputPath.length - 1);
16+
} else if (!hasSlash && needsSlash) {
17+
return `${inputPath}/`;
18+
} else {
19+
return inputPath;
20+
}
21+
}
22+
23+
const getPublicUrl = appPackageJson =>
24+
envPublicUrl || require(appPackageJson).homepage;
25+
26+
// We use `PUBLIC_URL` environment variable or "homepage" field to infer
27+
// "public path" at which the app is served.
28+
// Webpack needs to know it to put the right <script> hrefs into HTML even in
29+
// single-page apps that may serve index.html for nested URLs like /todos/42.
30+
// We can't use a relative path in HTML because we don't want to load something
31+
// like /todos/42/static/js/bundle.7289d.js. We have to know the root.
32+
function getServedPath(appPackageJson) {
33+
const publicUrl = getPublicUrl(appPackageJson);
34+
const servedUrl =
35+
envPublicUrl || (publicUrl ? url.parse(publicUrl).pathname : '/');
36+
return ensureSlash(servedUrl, true);
37+
}
38+
39+
const moduleFileExtensions = [
40+
'web.mjs',
41+
'mjs',
42+
'web.js',
43+
'js',
44+
'web.ts',
45+
'ts',
46+
'web.tsx',
47+
'tsx',
48+
'json',
49+
'web.jsx',
50+
'jsx',
51+
];
52+
53+
const resolveModule = (resolveFn, filePath) => {
54+
const extension = moduleFileExtensions.find(extension =>
55+
fs.existsSync(resolveFn(`${filePath}.${extension}`))
56+
);
57+
58+
if (extension) {
59+
return resolveFn(`${filePath}.${extension}`);
60+
}
61+
62+
return resolveFn(`${filePath}.js`);
63+
};
64+
65+
module.exports = {
66+
dotenv: resolveApp('.env'),
67+
appPath: resolveApp('.'),
68+
appBuild: resolveApp('build'),
69+
appExtension: resolveApp('extension'),
70+
appDev: resolveApp('dev'),
71+
appPublic: resolveApp('public'),
72+
appHtml: resolveApp('public/index.html'),
73+
appTemplate: resolveApp('config/template.html'),
74+
appOptionsJs: resolveModule(resolveApp, 'src/options/index'),
75+
appPopupJs: resolveModule(resolveApp, 'src/popup/index'),
76+
appSidebarJs: resolveModule(resolveApp, 'src/sidebar/index'),
77+
appBackgroundJs: resolveModule(resolveApp, 'src/background/index'),
78+
appContentJs: resolveModule(resolveApp, 'src/content_scripts/index'),
79+
appPackageJson: resolveApp('package.json'),
80+
appSrc: resolveApp('src'),
81+
appTsConfig: resolveApp('tsconfig.json'),
82+
yarnLockFile: resolveApp('yarn.lock'),
83+
testsSetup: resolveModule(resolveApp, 'src/setupTests'),
84+
proxySetup: resolveApp('src/setupProxy.js'),
85+
appNodeModules: resolveApp('node_modules'),
86+
publicUrl: getPublicUrl(resolveApp('package.json')),
87+
servedPath: getServedPath(resolveApp('package.json')),
88+
};
89+
90+
91+
92+
module.exports.moduleFileExtensions = moduleFileExtensions;

config/template.html

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
4+
<head>
5+
<meta charset="utf-8" />
6+
<title>
7+
<%= htmlWebpackPlugin.options.title %>
8+
</title>
9+
</head>
10+
11+
<body style="background-color: #fbfafa;">
12+
<div id="root"></div>
13+
</body>
14+
15+
</html>

0 commit comments

Comments
 (0)