From a614ee4e8caecc564b3b1daee9ff1496a148f667 Mon Sep 17 00:00:00 2001 From: Shin'ya Ueoka Date: Sun, 1 Oct 2017 22:00:31 +0900 Subject: install babel-minify-webpack-plugin --- package.json | 1 + 1 file changed, 1 insertion(+) (limited to 'package.json') diff --git a/package.json b/package.json index 42da3a7..2a255c8 100644 --- a/package.json +++ b/package.json @@ -20,6 +20,7 @@ "babel-cli": "^6.24.1", "babel-eslint": "^7.2.3", "babel-loader": "^7.1.1", + "babel-minify-webpack-plugin": "^0.2.0", "babel-plugin-transform-react-jsx": "^6.24.1", "babel-preset-es2015": "^6.24.1", "babel-preset-react": "^6.24.1", -- cgit v1.2.3 From b8a3e431c7d519af20f7aac96f649570f8f386da Mon Sep 17 00:00:00 2001 From: Shin'ya Ueoka Date: Sun, 1 Oct 2017 22:02:14 +0900 Subject: add build step --- package.json | 4 +++- webpack.config.js | 12 +++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) (limited to 'package.json') diff --git a/package.json b/package.json index 2a255c8..f2fe0ca 100644 --- a/package.json +++ b/package.json @@ -2,8 +2,10 @@ "name": "vim-vixen", "description": "Vim vixen", "scripts": { - "start": "webpack -w --debug", + "start": "webpack -w -d", "lint": "eslint --ext .jsx,.js src", + "build": "NODE_ENV=production webpack --progress --display-error-details", + "lint": "eslint src", "test": "karma start" }, "repository": { diff --git a/webpack.config.js b/webpack.config.js index 977ea75..16d437f 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -1,10 +1,11 @@ -var HtmlWebpackPlugin = require('html-webpack-plugin'); -var path = require('path'); +const MinifyPlugin = require("babel-minify-webpack-plugin"); +const HtmlWebpackPlugin = require('html-webpack-plugin'); +const path = require('path'); const src = path.resolve(__dirname, 'src'); const dist = path.resolve(__dirname, 'build'); -module.exports = { +config = { entry: { content: path.join(src, 'content'), settings: path.join(src, 'settings'), @@ -56,3 +57,8 @@ module.exports = { }) ] }; +if (process.env.NODE_ENV === 'production') { + config.plugins.push(new MinifyPlugin()); +} + +module.exports = config -- cgit v1.2.3 From 2e7301b6ba71de02b6da0ab0b170a2b313377d5a Mon Sep 17 00:00:00 2001 From: Shin'ya Ueoka Date: Sun, 1 Oct 2017 22:46:37 +0900 Subject: add package step --- .gitignore | 1 + manifest.json | 12 +++++++++++- package.json | 1 + package.sh | 20 ++++++++++++++++++++ 4 files changed, 33 insertions(+), 1 deletion(-) create mode 100755 package.sh (limited to 'package.json') diff --git a/.gitignore b/.gitignore index d49756d..2515a99 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ /node_modules/ /build/ +*.zip diff --git a/manifest.json b/manifest.json index 216023b..360b166 100644 --- a/manifest.json +++ b/manifest.json @@ -3,6 +3,15 @@ "name": "Vim Vixen", "description": "Vim Vixen", "version": "0.0.1", + "icons": { + "48": "resources/icon_48x48.png", + "96": "resources/icon_96x96.png" + }, + "applications": { + "gecko": { + "id": "vim-vixen@i-beam.org" + } + }, "content_scripts": [ { "matches": [ "http://*/*", "https://*/*" ], @@ -21,7 +30,8 @@ "tabs" ], "web_accessible_resources": [ - "build/console.html" + "build/console.html", + "build/console.js" ], "options_ui": { "page": "build/settings.html" diff --git a/package.json b/package.json index f2fe0ca..49b191a 100644 --- a/package.json +++ b/package.json @@ -5,6 +5,7 @@ "start": "webpack -w -d", "lint": "eslint --ext .jsx,.js src", "build": "NODE_ENV=production webpack --progress --display-error-details", + "package": "npm run build && ./package.sh", "lint": "eslint src", "test": "karma start" }, diff --git a/package.sh b/package.sh new file mode 100755 index 0000000..34535ba --- /dev/null +++ b/package.sh @@ -0,0 +1,20 @@ +#!/bin/sh + +MANIFEST="manifest.json" + +version=$(jq -r '.version' $MANIFEST) + +icons=$(jq -r '.icons[]' $MANIFEST) +content_scripts=$(jq -r '.content_scripts[].js[]' $MANIFEST) +background_scripts=$(jq -r '.background.scripts[]' $MANIFEST) +web_accessible_resources=$(jq -r '.web_accessible_resources[]' $MANIFEST) +options_ui=$(jq -r '.options_ui.page' $MANIFEST) +options_scripts="" +for html in $options_ui; do + scripts=$(grep -Po "(?<=src=['\"])[^'\"]*" "$html") + for js in $scripts; do + options_scripts="$options_scripts $(dirname $html)/$js" + done +done + +zip ${version}.zip $MANIFEST $icons $content_scripts $background_scripts $web_accessible_resources $options_ui $options_scripts -- cgit v1.2.3