Skip to content
This repository has been archived by the owner on Apr 29, 2022. It is now read-only.

Commit

Permalink
start to port extension to Firefox
Browse files Browse the repository at this point in the history
  • Loading branch information
sballesteros committed Dec 1, 2019
1 parent c23f666 commit fb4d32c
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 22 deletions.
20 changes: 18 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,21 +134,37 @@ To add stories, add a file that ends with `.stories.js` in the `./src/components

#### Development

For chrome:
##### Chrome

1. Run `npm run extension:watch` that will build and watch the extension in the
`extension` directory. ! DO NOT EDIT THE FILES THERE or do not tack them on
git, with the exception of manifest.json, fonts, and popup.html.
2. Navigate to `chrome://extensions/`, be sure to toggle the "developer mode",
click on "load unpacked" and select the content of the `extension` directory.


##### Firefox

1. Run `npm run extension:watch-firefox` that will build and watch the extension in the
`extension` directory. ! DO NOT EDIT THE FILES THERE or do not tack them on
git, with the exception of manifest.json, fonts, and popup.html.
2. Navigate to `about:debugging`, and click on "Load Temporary Add-on" and
select the `manifest.json` file.


#### Production

For chrome:
##### Chrome

1. Run `npm run extension:build`
2. Navigate to `chrome://extensions/`, be sure to toggle the "developer mode",
click on "load unpacked" and select the content of the `extension` directory.

##### Firefox

1. Run `npm run extension:build-firefox`


### Tests

Once cloudant and redis are running run:
Expand Down
17 changes: 17 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
"azure:reset-cache": "source env.private.sh && babel-node ./scripts/reset-redis.js --cache-only",
"log-cloudant": "docker logs cloudant-developer",
"extension:watch": "webpack --config webpack-extension.config.js --watch --mode development",
"extension:watch-firefox": "cross-env EXTENSION_BROwSER_ENV=firefox webpack --config webpack-extension.config.js --watch --mode development",
"extension:build": "cross-env NODE_ENV=production webpack --config webpack-extension.config.js --mode production",
"extension:build-firefox": "cross-env NODE_ENV=production cross-env EXTENSION_BROwSER_ENV=firefox webpack --config webpack-extension.config.js --mode production",
"start": "babel-node ./src/dev-server.js | pino-pretty",
"start:app-prod": "node ./dist/server.js",
"start:service-prod": "node ./dist/service.js",
Expand Down Expand Up @@ -182,6 +184,7 @@
"postcss-nested": "^4.2.1",
"postcss-plugin-namespace": "0.0.2",
"postcss-preset-env": "^6.7.0",
"postcss-replace": "^1.1.0",
"postcss-url": "^8.0.0",
"prettier": "^1.19.1",
"style-loader": "^1.0.0",
Expand Down
45 changes: 25 additions & 20 deletions src/components/extension-fonts.css
Original file line number Diff line number Diff line change
@@ -1,90 +1,95 @@
/*
* Note: {{ EXTENSION_ROOT }} is replaced by `moz-extension` or
* `chrome-extension` by the postcss-replace plugin (see webpack config)
*/

/* open-sans-300 - latin */
@font-face {
font-family: 'Open Sans';
font-style: normal;
font-weight: 300;
src: local('Open Sans Light'), local('OpenSans-Light'),
url('chrome-extension://__MSG_@@extension_id__/fonts/open-sans-v17-latin-300.woff2') format('woff2'), /* Chrome 26+, Opera 23+, Firefox 39+ */
url('chrome-extension://__MSG_@@extension_id__/fonts/open-sans-v17-latin-300.woff') format('woff'); /* Chrome 6+, Firefox 3.6+, IE 9+, Safari 5.1+ */
url('{{ EXTENSION_ROOT }}://__MSG_@@extension_id__/fonts/open-sans-v17-latin-300.woff2') format('woff2'), /* Chrome 26+, Opera 23+, Firefox 39+ */
url('{{ EXTENSION_ROOT }}://__MSG_@@extension_id__/fonts/open-sans-v17-latin-300.woff') format('woff'); /* Chrome 6+, Firefox 3.6+, IE 9+, Safari 5.1+ */
}
/* open-sans-300italic - latin */
@font-face {
font-family: 'Open Sans';
font-style: italic;
font-weight: 300;
src: local('Open Sans Light Italic'), local('OpenSans-LightItalic'),
url('chrome-extension://__MSG_@@extension_id__/fonts/open-sans-v17-latin-300italic.woff2') format('woff2'), /* Chrome 26+, Opera 23+, Firefox 39+ */
url('chrome-extension://__MSG_@@extension_id__/fonts/open-sans-v17-latin-300italic.woff') format('woff'); /* Chrome 6+, Firefox 3.6+, IE 9+, Safari 5.1+ */
url('{{ EXTENSION_ROOT }}://__MSG_@@extension_id__/fonts/open-sans-v17-latin-300italic.woff2') format('woff2'), /* Chrome 26+, Opera 23+, Firefox 39+ */
url('{{ EXTENSION_ROOT }}://__MSG_@@extension_id__/fonts/open-sans-v17-latin-300italic.woff') format('woff'); /* Chrome 6+, Firefox 3.6+, IE 9+, Safari 5.1+ */
}
/* open-sans-regular - latin */
@font-face {
font-family: 'Open Sans';
font-style: normal;
font-weight: 400;
src: local('Open Sans Regular'), local('OpenSans-Regular'),
url('chrome-extension://__MSG_@@extension_id__/fonts/open-sans-v17-latin-regular.woff2') format('woff2'), /* Chrome 26+, Opera 23+, Firefox 39+ */
url('chrome-extension://__MSG_@@extension_id__/fonts/open-sans-v17-latin-regular.woff') format('woff'); /* Chrome 6+, Firefox 3.6+, IE 9+, Safari 5.1+ */
url('{{ EXTENSION_ROOT }}://__MSG_@@extension_id__/fonts/open-sans-v17-latin-regular.woff2') format('woff2'), /* Chrome 26+, Opera 23+, Firefox 39+ */
url('{{ EXTENSION_ROOT }}://__MSG_@@extension_id__/fonts/open-sans-v17-latin-regular.woff') format('woff'); /* Chrome 6+, Firefox 3.6+, IE 9+, Safari 5.1+ */
}
/* open-sans-italic - latin */
@font-face {
font-family: 'Open Sans';
font-style: italic;
font-weight: 400;
src: local('Open Sans Italic'), local('OpenSans-Italic'),
url('chrome-extension://__MSG_@@extension_id__/fonts/open-sans-v17-latin-italic.woff2') format('woff2'), /* Chrome 26+, Opera 23+, Firefox 39+ */
url('chrome-extension://__MSG_@@extension_id__/fonts/open-sans-v17-latin-italic.woff') format('woff'); /* Chrome 6+, Firefox 3.6+, IE 9+, Safari 5.1+ */
url('{{ EXTENSION_ROOT }}://__MSG_@@extension_id__/fonts/open-sans-v17-latin-italic.woff2') format('woff2'), /* Chrome 26+, Opera 23+, Firefox 39+ */
url('{{ EXTENSION_ROOT }}://__MSG_@@extension_id__/fonts/open-sans-v17-latin-italic.woff') format('woff'); /* Chrome 6+, Firefox 3.6+, IE 9+, Safari 5.1+ */
}
/* open-sans-600 - latin */
@font-face {
font-family: 'Open Sans';
font-style: normal;
font-weight: 600;
src: local('Open Sans SemiBold'), local('OpenSans-SemiBold'),
url('chrome-extension://__MSG_@@extension_id__/fonts/open-sans-v17-latin-600.woff2') format('woff2'), /* Chrome 26+, Opera 23+, Firefox 39+ */
url('chrome-extension://__MSG_@@extension_id__/fonts/open-sans-v17-latin-600.woff') format('woff'); /* Chrome 6+, Firefox 3.6+, IE 9+, Safari 5.1+ */
url('{{ EXTENSION_ROOT }}://__MSG_@@extension_id__/fonts/open-sans-v17-latin-600.woff2') format('woff2'), /* Chrome 26+, Opera 23+, Firefox 39+ */
url('{{ EXTENSION_ROOT }}://__MSG_@@extension_id__/fonts/open-sans-v17-latin-600.woff') format('woff'); /* Chrome 6+, Firefox 3.6+, IE 9+, Safari 5.1+ */
}
/* open-sans-600italic - latin */
@font-face {
font-family: 'Open Sans';
font-style: italic;
font-weight: 600;
src: local('Open Sans SemiBold Italic'), local('OpenSans-SemiBoldItalic'),
url('chrome-extension://__MSG_@@extension_id__/fonts/open-sans-v17-latin-600italic.woff2') format('woff2'), /* Chrome 26+, Opera 23+, Firefox 39+ */
url('chrome-extension://__MSG_@@extension_id__/fonts/open-sans-v17-latin-600italic.woff') format('woff'); /* Chrome 6+, Firefox 3.6+, IE 9+, Safari 5.1+ */
url('{{ EXTENSION_ROOT }}://__MSG_@@extension_id__/fonts/open-sans-v17-latin-600italic.woff2') format('woff2'), /* Chrome 26+, Opera 23+, Firefox 39+ */
url('{{ EXTENSION_ROOT }}://__MSG_@@extension_id__/fonts/open-sans-v17-latin-600italic.woff') format('woff'); /* Chrome 6+, Firefox 3.6+, IE 9+, Safari 5.1+ */
}
/* open-sans-700 - latin */
@font-face {
font-family: 'Open Sans';
font-style: normal;
font-weight: 700;
src: local('Open Sans Bold'), local('OpenSans-Bold'),
url('chrome-extension://__MSG_@@extension_id__/fonts/open-sans-v17-latin-700.woff2') format('woff2'), /* Chrome 26+, Opera 23+, Firefox 39+ */
url('chrome-extension://__MSG_@@extension_id__/fonts/open-sans-v17-latin-700.woff') format('woff'); /* Chrome 6+, Firefox 3.6+, IE 9+, Safari 5.1+ */
url('{{ EXTENSION_ROOT }}://__MSG_@@extension_id__/fonts/open-sans-v17-latin-700.woff2') format('woff2'), /* Chrome 26+, Opera 23+, Firefox 39+ */
url('{{ EXTENSION_ROOT }}://__MSG_@@extension_id__/fonts/open-sans-v17-latin-700.woff') format('woff'); /* Chrome 6+, Firefox 3.6+, IE 9+, Safari 5.1+ */
}
/* open-sans-700italic - latin */
@font-face {
font-family: 'Open Sans';
font-style: italic;
font-weight: 700;
src: local('Open Sans Bold Italic'), local('OpenSans-BoldItalic'),
url('chrome-extension://__MSG_@@extension_id__/fonts/open-sans-v17-latin-700italic.woff2') format('woff2'), /* Chrome 26+, Opera 23+, Firefox 39+ */
url('chrome-extension://__MSG_@@extension_id__/fonts/open-sans-v17-latin-700italic.woff') format('woff'); /* Chrome 6+, Firefox 3.6+, IE 9+, Safari 5.1+ */
url('{{ EXTENSION_ROOT }}://__MSG_@@extension_id__/fonts/open-sans-v17-latin-700italic.woff2') format('woff2'), /* Chrome 26+, Opera 23+, Firefox 39+ */
url('{{ EXTENSION_ROOT }}://__MSG_@@extension_id__/fonts/open-sans-v17-latin-700italic.woff') format('woff'); /* Chrome 6+, Firefox 3.6+, IE 9+, Safari 5.1+ */
}
/* open-sans-800 - latin */
@font-face {
font-family: 'Open Sans';
font-style: normal;
font-weight: 800;
src: local('Open Sans ExtraBold'), local('OpenSans-ExtraBold'),
url('chrome-extension://__MSG_@@extension_id__/fonts/open-sans-v17-latin-800.woff2') format('woff2'), /* Chrome 26+, Opera 23+, Firefox 39+ */
url('chrome-extension://__MSG_@@extension_id__/fonts/open-sans-v17-latin-800.woff') format('woff'); /* Chrome 6+, Firefox 3.6+, IE 9+, Safari 5.1+ */
url('{{ EXTENSION_ROOT }}://__MSG_@@extension_id__/fonts/open-sans-v17-latin-800.woff2') format('woff2'), /* Chrome 26+, Opera 23+, Firefox 39+ */
url('{{ EXTENSION_ROOT }}://__MSG_@@extension_id__/fonts/open-sans-v17-latin-800.woff') format('woff'); /* Chrome 6+, Firefox 3.6+, IE 9+, Safari 5.1+ */
}
/* open-sans-800italic - latin */
@font-face {
font-family: 'Open Sans';
font-style: italic;
font-weight: 800;
src: local('Open Sans ExtraBold Italic'), local('OpenSans-ExtraBoldItalic'),
url('chrome-extension://__MSG_@@extension_id__/fonts/open-sans-v17-latin-800italic.woff2') format('woff2'), /* Chrome 26+, Opera 23+, Firefox 39+ */
url('chrome-extension://__MSG_@@extension_id__/fonts/open-sans-v17-latin-800italic.woff') format('woff'); /* Chrome 6+, Firefox 3.6+, IE 9+, Safari 5.1+ */
url('{{ EXTENSION_ROOT }}://__MSG_@@extension_id__/fonts/open-sans-v17-latin-800italic.woff2') format('woff2'), /* Chrome 26+, Opera 23+, Firefox 39+ */
url('{{ EXTENSION_ROOT }}://__MSG_@@extension_id__/fonts/open-sans-v17-latin-800italic.woff') format('woff'); /* Chrome 6+, Firefox 3.6+, IE 9+, Safari 5.1+ */
}
8 changes: 8 additions & 0 deletions webpack-extension.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,14 @@ module.exports = {
);
}
}),
require('postcss-replace')({
data: {
EXTENSION_ROOT:
process.env.EXTENSION_BROwSER_ENV === 'firefox'
? 'moz-extension'
: 'chrome-extension'
}
}),
require('postcss-preset-env')({
/* see: https://github.com/csstools/postcss-preset-env/issues/32 */
browsers: 'last 2 versions',
Expand Down

0 comments on commit fb4d32c

Please sign in to comment.