Skip to content

Commit d5c067c

Browse files
authored
chore: update examples (Kocal#345)
.
1 parent 392091c commit d5c067c

File tree

23 files changed

+3836
-2076
lines changed

23 files changed

+3836
-2076
lines changed

examples/full-airbnb/package.json

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,25 +19,26 @@
1919
"axios": "^0.18.0",
2020
"vue": "^2.5.17",
2121
"vue-router": "^3.0.1",
22-
"vuex": "^3.0.1"
22+
"vuex": "^3.0.1",
23+
"webextension-polyfill": "^0.3.1"
2324
},
2425
"devDependencies": {
2526
"@babel/core": "^7.1.2",
2627
"@babel/plugin-proposal-optional-chaining": "^7.0.0",
2728
"@babel/preset-env": "^7.1.0",
28-
"@types/chrome": "^0.0.74",
2929
"babel-eslint": "^10.0.1",
30-
"babel-loader": "^8.0.4",
30+
"babel-loader": "^8.0.2",
3131
"copy-webpack-plugin": "^4.5.3",
3232
"cross-env": "^5.2.0",
3333
"css-loader": "^0.28.11",
34+
"ejs": "^2.6.1",
3435
"eslint": "^5.7.0",
35-
"eslint-config-airbnb-base": "^13.1.0",
36+
"eslint-config-airbnb-base": "^13.0.0",
3637
"eslint-config-prettier": "^3.1.0",
3738
"eslint-friendly-formatter": "^4.0.1",
3839
"eslint-import-resolver-webpack": "^0.10.1",
3940
"eslint-loader": "^2.1.1",
40-
"eslint-plugin-import": "^2.14.0",
41+
"eslint-plugin-import": "^2.12.0",
4142
"eslint-plugin-prettier": "^3.0.0",
4243
"eslint-plugin-vue": "^5.0.0-beta.3",
4344
"file-loader": "^1.1.11",
@@ -49,6 +50,7 @@
4950
"sass-loader": "^7.1.0",
5051
"vue-loader": "^15.4.2",
5152
"vue-template-compiler": "^2.5.17",
53+
"web-ext-types": "^2.1.0",
5254
"webpack": "^4.20.2",
5355
"webpack-chrome-extension-reloader": "^0.8.3",
5456
"webpack-cli": "^3.1.2",
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
import store from './store';
22

3+
global.browser = require('webextension-polyfill');
4+
35
alert(`Hello ${store.getters.foo}!`);

examples/full-airbnb/src/options/options.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
<meta charset="UTF-8">
55
<title>full-airbnb - Options</title>
66
<link rel="stylesheet" href="options.css">
7+
<% if (NODE_ENV === 'development') { %>
8+
<!-- Load some resources only in development environment -->
9+
<% } %>
710
</head>
811
<body>
912
<div id="app"></div>

examples/full-airbnb/src/options/options.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import Vue from 'vue';
22
import App from './App';
33

4+
global.browser = require('webextension-polyfill');
5+
46
/* eslint-disable no-new */
57
new Vue({
68
el: '#app',

examples/full-airbnb/src/popup/popup.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
<meta charset="UTF-8">
55
<title>Title</title>
66
<link rel="stylesheet" href="popup.css">
7+
<% if (NODE_ENV === 'development') { %>
8+
<!-- Load some resources only in development environment -->
9+
<% } %>
710
</head>
811
<body>
912
<div id="app">

examples/full-airbnb/src/popup/popup.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import App from './App';
33
import store from '../store';
44
import router from './router';
55

6+
global.browser = require('webextension-polyfill');
7+
68
/* eslint-disable no-new */
79
new Vue({
810
el: '#app',

examples/full-airbnb/webpack.config.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
const webpack = require('webpack');
2+
const ejs = require('ejs');
23
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
34
const WebpackShellPlugin = require('webpack-shell-plugin');
45
const CopyWebpackPlugin = require('copy-webpack-plugin');
@@ -60,8 +61,8 @@ const config = {
6061
}),
6162
new CopyWebpackPlugin([
6263
{ from: 'icons', to: 'icons', ignore: ['icon.xcf'] },
63-
{ from: 'popup/popup.html', to: 'popup/popup.html' },
64-
{ from: 'options/options.html', to: 'options/options.html' },
64+
{ from: 'popup/popup.html', to: 'popup/popup.html', transform: transformHtml },
65+
{ from: 'options/options.html', to: 'options/options.html', transform: transformHtml },
6566
{
6667
from: 'manifest.json',
6768
to: 'manifest.json',
@@ -99,4 +100,10 @@ if (process.env.HMR === 'true') {
99100
]);
100101
}
101102

103+
function transformHtml(content) {
104+
return ejs.render(content.toString(), {
105+
...process.env,
106+
});
107+
}
108+
102109
module.exports = config;

0 commit comments

Comments
 (0)