From 11f5efebdff60b2d54058f0edf59648de9d93dae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Berson?= Date: Thu, 20 Jun 2019 12:27:33 +0200 Subject: [PATCH] move bundles to dist folder and make minification optional --- .gitignore | 5 +---- manifest.json | 4 ++-- package.json | 8 ++++++-- rollup.config.js | 11 ++++++++--- 4 files changed, 17 insertions(+), 11 deletions(-) diff --git a/.gitignore b/.gitignore index 61634d1..b947077 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,2 @@ node_modules/ -background.bundle.js -background.bundle.js.map -content-script.bundle.js -content-script.bundle.js.map +dist/ diff --git a/manifest.json b/manifest.json index 295c6ae..3cbee65 100644 --- a/manifest.json +++ b/manifest.json @@ -17,12 +17,12 @@ }, "permissions": [ "http://*/*", "https://*/*","tabs", "activeTab", "webRequest", "webRequestBlocking","unlimitedStorage", "webNavigation", ""], "background": { - "scripts": ["background.bundle.js"] + "scripts": ["./dist/background.bundle.js"] }, "content_scripts": [{ "matches" : ["http://*/*", "https://*/*"], "match_about_blank": true, - "js": ["content-script.bundle.js"], + "js": ["./dist/content-script.bundle.js"], "all_frames": true, "run_at": "document_end" }], diff --git a/package.json b/package.json index 6ec8252..bf52f12 100644 --- a/package.json +++ b/package.json @@ -2,10 +2,14 @@ "description": "Local sheriff is a reconnaissance tool in your browser for your data.", "main": "background.js", "scripts": { - "build": "rollup --config rollup.config.js", + "clean": "rm -frv dist", + "build": "rollup --config rollup.config.js --environment BUILD:production", + "prestart": "npm run clean", "watch": "rollup --config rollup.config.js --watch", + "prestart": "npm run clean", "lint": "web-ext lint", - "start": "concurrently 'npm run watch' 'web-ext run --source-dir . --firefox /usr/bin/firefox'" + "start": "concurrently 'npm run watch' 'web-ext run --source-dir . --firefox /usr/bin/firefox'", + "prestart": "npm run clean" }, "repository": { "type": "git", diff --git a/rollup.config.js b/rollup.config.js index e65899f..c53950a 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -3,20 +3,25 @@ import resolve from 'rollup-plugin-node-resolve'; import json from 'rollup-plugin-json'; import compiler from '@ampproject/rollup-plugin-closure-compiler'; +const mode = process.env.BUILD === 'production' ? 'production' : 'development'; + const plugins = [ json(), resolve({ preferBuiltins: false, }), commonjs(), - compiler(), ]; +if (mode === 'production') { + plugins.push(compiler()); +} + export default [ { input: './background.js', output: { - file: 'background.bundle.js', + file: './dist/background.bundle.js', format: 'iife', name: 'localSheriff', sourcemap: true, @@ -26,7 +31,7 @@ export default [ { input: './scripts/content-script.js', output: { - file: 'content-script.bundle.js', + file: './dist/content-script.bundle.js', format: 'iife', name: 'localSheriff', sourcemap: true,