Git Product home page Git Product logo

vue-cli-plugin-browser-extension's Introduction

vue-cli-plugin-browser-extension

Browser extension development plugin for vue-cli 3.x

What does it do?

This is intended to be a [email protected] replacement for Kocal/vue-web-extension v1 (now, Kocal/vue-web-extension is a preset using this plugin).

This plugin changes the serve command for your vue applications. This new command is only for running a livereload server while testing out your browser extension.

This removes the entrypoint of src/main.js, and as such will not scaffold a general vue app.

Packaging and deploying will still be done with yarn build and zipping in up for Chrome, Firefox, or whichever other browser you wish to develop for.

It makes some assumptions about your project setup. I hope to be able to scaffold an app so that identifying the below in unnecessary.

.
├── public/
│   ├── _locales/
│   │   └── en/
│   │       └── messages.json
│   ├── icons/
│   │   └── Icons for your extension. Should include a 16, 19, 38, 48, and 128px square image
│   └── browser-extension.html (default target html template)
├── src/
│   ├── assets/
│   │   └── Static assets in use in your app, like logo.png
│   ├── components/
│   │   └── HelloWorld.vue (modified)
│   ├── content-scripts
│   │   └── content-script.js
│   ├── devtools/ (asked during project generation)
│   │   ├── App.vue
│   │   └── main.js
│   ├── options/ (asked during project generation)
│   │   ├── App.vue
│   │   └── main.js
│   ├── popup/ (asked during project generation)
│   │   ├── App.vue
│   │   └── main.js
│   ├── override/ (asked during project generation)
│   │   ├── App.vue
│   │   └── main.js
│   └── standalone/ (asked during project generation)
│      ├── App.vue
│      └── main.js
├── background.js
└── manifest.json

System Dependencies

If you wish to use the signing key functionality you will need to have openssl available on your system.

Adding to your project

This can be added to your vuejs project by one of the following methods:

  • Using the vue ui and searching for this project
  • Using the vue cli vue add browser-extension command

Usage

Running the Livereload server. This will build and write to the local dist directory.

This plugin will respect the outputDir setting, however it cannot read into passed CLI args, so if you require a custom output dir, be sure to add it in your vue.config.js file. You can then add this as an unpacked plugin to your browser, and will continue to update as you make changes.

NOTE: you cannot get HMR support in the popup window, however, closing and reopening will refresh your content.

yarn serve
yarn build

Plugin options

Plugin options can be set inside your vue.config.js:

// vue.config.js
module.exports = {
  pluginOptions: {
    browserExtension: {
      // options...
    },
  },
};
  • components

    • Type: Object.<string, boolean>

    The browser extension components that will be managed by this plugin.

    Valid components are:

    • background
    • popup
    • options
    • contentScripts
    • override
    • standalone
    • devtools
    components: {
      background: true,
      contentScripts: true
    }
  • componentOptions

    • Type: Object.<string, Object>

    See Component options.

  • extensionReloaderOptions

    • Type: Object.<string, Object>

    See available options in webpack-extension-reloader.

  • manifestSync

    • Type: Array<string>
    • Default: ['version']

    Array containing names of manifest.json keys that will be automatically synced with package.json on build.

    Currently, the only supported keys are version and description.

  • manifestTransformer

    • Type: Function

    Function to modify the manifest JSON outputted by this plugin.

    An example use case is adding or removing permissions depending on which browser is being targeted.

    manifestTransformer: (manifest) => {
      if (process.env.BROWSER === 'chrome') {
        manifest.permissions.push('pageCapture');
      }
      return manifest;
    };
  • modesToZip

    Deprecated. Any mode will be zipped to the artifacts dir, when NODE_ENV=production (the default in the normal yarn build). For more information on how to set NODE_ENV=production in other modes see Vue CLI docs – Example Staging Mode

  • artifactsDir

    • Type: string
    • Default: './artifacts'

    Directory where the zipped browser extension should get created.

  • artifactFilename

    • Type: Function
    • Default: ({name, version, mode}) => `${name}-v${version}-${mode}.zip`

    Optional function to generate a custom artifact filename. Useful for naming builds for different browsers.

    The function takes a single object parameter containing:

    • name - Name from package.json
    • version - Version from package.json
    • mode - Vue CLI mode such as 'production'

    For example,

    // vue.config.js
    module.exports = {
      pluginOptions: {
        browserExtension: {
          artifactFilename: ({ name, version, mode }) => {
            if (mode === 'production') {
              return `${name}-v${version}-${process.env.BROWSER}.zip`;
            }
            return `${name}-v${version}-${process.env.BROWSER}-${mode}.zip`;
          },
        },
      },
    };

Component options

Some browser extension components have additional options which can be set as follows:

// vue.config.js
module.exports = {
  pluginOptions: {
    browserExtension: {
      componentOptions: {
        // <name of component>: <options>
        // e.g.
        contentScripts: {
          entries: {
            content1: 'src/content-script1.js',
            content2: 'src/content-script2.js',
          },
        },
      },
    },
  },
};

background

  • entry

    • Type: string|Array<string>

    Background script as webpack entry using the single entry shorthand syntax.

    background: {
      entry: 'src/my-background-script.js';
    }

contentScripts

  • entries

    • Type: {[entryChunkName: string]: string|Array<string>}

    Content scripts as webpack entries using using the object syntax.

    contentScripts: {
      entries: {
        'my-first-content-script': 'src/content-script.js',
        'my-second-content-script': 'src/my-second-script.js'
      }
    }

Internationalization

Some boilerplate for internationalization has been added. This follows the i18n (chrome|WebExtention) spec. Provided for you is the default_locale option in the manifest, and a _locales directory. There is some basic usage of it in the manifest, as well as in some of the boilerplate files. Since this is largely an out of the box solution provided by the browsers, it is heavily encouraged to utilize it. If you do not want to translate your app, simply delete the public/_locales directory, and no longer use the browser.i18n methods.

Browser Polyfills

This plugin by default adds in the official mozilla webextension polyfill to the build. The opinion of this plugin is that developers should be building cross platform, and should have reasonable tooling to do so. By emphasizing cross platform first, your application will be adhering to the community standards, be ready for distribution to other extension stores, and avoid developing against browser APIs that may have no equivalent. The polyfill is a no-op on firefox, and only takes up 20.5kb unminified.

If you still feel strongly to not include the polyfill, then this is what you need to add to your webpack chain to do so.

vue.config.js

module.exports = {
  chainWebpack(config) {
    config.plugins.delete('provide-webextension-polyfill');
    config.module.rules.delete('provide-webextension-polyfill');
  },
};

Testing

This library is following the standard styling of vue projects, and those are really the only tests to perform.

yarn test

Roadmap

  • A preset
  • Cleanup the dist-zip directory

Credits

vue-cli-plugin-browser-extension's People

Contributors

adambullmer avatar dependabot[bot] avatar franciscolourenco avatar kocal avatar korziee avatar kunalaggarwal avatar mintonne avatar naokazuterada avatar siphomateke avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vue-cli-plugin-browser-extension's Issues

Uncaught (in promise) in popup

Uncaught (in promise) Objectmessage: "Could not establish connection. Receiving end does not exist."get message: ƒ ()arguments: (...)caller: (...)length: 0name: ""proto: ƒ ()[[Scopes]]: Scopes[0]proto: Object

i have a fresh vue cli install plus a fresh vue-cli-plugin-browser-extension install and get this error on serve.

Live reload clarification

Live reloading capabilities are mentioned a few times in the README, however this plugin does not support HMR.

It would be helpful if the distinction was made, and to know what live reload means exactly, in the context of the browser extension.

Thanks!


Related:

Yarn build error contenthash:8 not implemented in this context

yarn build was working for me, but it stopped working just today for some reason. I am getting the following error:


 error

Cannot convert undefined or null to object

 error  in css/[name].[contenthash:8].css

Path variable [contenthash:8] not implemented in this context: css/[name].[contenthash:8].css

 ERROR  Build failed with errors.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

I don't know if this is in your plugin or vue-cli or where the problem is.

Error: package.json not found

:~/DEV/EXTENSIONs$ vue add browser-extension

📦  Installing vue-cli-plugin-browser-extension...

+ [email protected]
updated 1 package and audited 21654 packages in 5.184s
found 0 vulnerabilities

✔  Successfully installed plugin: vue-cli-plugin-browser-extension

 ERROR  Error: package.json not found in /home/lsoave/DEV/EXTENSIONs
Error: package.json not found in /home/lsoave/DEV/EXTENSIONs
    at getPkg (/usr/local/share/.config/yarn/global/node_modules/@vue/cli/lib/invoke.js:44:11)
    at invoke (/usr/local/share/.config/yarn/global/node_modules/@vue/cli/lib/invoke.js:55:15)
    at module.exports.args (/usr/local/share/.config/yarn/global/node_modules/@vue/cli/lib/invoke.js:188:10)
    at add (/usr/local/share/.config/yarn/global/node_modules/@vue/cli/lib/add.js:37:5)
    at processTicksAndRejections (internal/process/task_queues.js:86:5)

Optimize scaffold targets

Consider using the same scaffold template for each of the webpage components (popup, devtools, options, override, standalone), since their scaffold target is the only thing that changes.

Also maybe only reuse the default index.html file instead of a new entry html file by default. It's likely that the base entrypoint won't change much between these implementation, other than the webpack output, so maybe it makes sense to not force the user into duplicate code out of the box.

Popup HTML unnecessary boilerplate

The popup.html file is being generated with unnecessary boilerplate. Should remove the css and js links from the template as they will get generated and added at build time

@click event not working on options page

Hello,
I'm starting to use this plugin for a chrome extension and noticed that the @click event doesn't trigger in the options page components, but works fine in the popup page. Also if I set to not open the embedded way using open_in_tab = true it works.

Is there a way to make the @click trigger when open_in_tab = false? This is the default behavior if nothing is changed after installing this plugin.

Feature: Hide Webpack messages about zip file exceeding the recommended size limit

Webpack currently shows a message like the following when building a project for production:

asset size limit: The following asset(s) exceed the recommended size limit (244 KiB).
This can impact web performance.
Assets:
  ../dist-zip/<project-name>-v<version>.zip (945 KiB)

I don't think this message is relevant and if possible should be hidden.

regarding key warning

When key.pem file is not present, we get this warning.

No `key.pem` file detected. This is problematic only if you are publishing an existing extension`

However, if user has specified key in manifest.json this is not required.

Locales support

Is it possible to have locales support?

I think it needs to add an extra CopyWebpackPlugin usage for _locales folder and maybe an extra check for pluginOptions.manifestSync.includes('default_locale').

Awesome plugin, thank you!

Use NODE_ENV instead of api.service.mode

According to the Vue CLI docs, "staging" and other production-like envs can be used by setting the mode to staging, and setting NODE_ENV=production.

Currently vue-cli-plugin-browser-extension relies on mode being 'production' or in adding other modes to pluginOptions.browserExtension.modesToZip.

Perhaps it would make more sense to rely on NODE_ENV=production so that the plugin works like Vue CLI.

image

Extension stop working after build

The extension I created using this plugin is working fine in the development mode, however, when I do yarn build and load up the unpacked into the Chrome extensions, it does not work anymore! I get no error anywhere, but I can not see any of my background.js cosole.logs! Any idea where should I start to dig in order to fix it?

Create example repo

Fully scaffold the app to have a reasonable example for how an application structure may look, including typescript, vuex, and vue-router.

Might also want to include a monorepo setup where other build targets such as web or electron are also included to show how this could all be put into harmony.

HMR

Is HMR supposed to be working? Not working in the options page for me. Thanks!

Fresh install with vue cli 4 leads to several errors in chrome extension

I just tried to setup a project with vue cli 4 and I got as far as generating the right output files with npm run serve and npm run build.

However the chrome extension logs several error messages:
chromlogs

  1. found unexpected key 'browser_style'
    "options_ui": { "page": "options.html", "browser_style": true },

  2. Uncaught SyntaxError: missing ) after argument list
    js/popup.js:1209 (anonymous function)

  3. Uncaught SyntaxError: missing ) after argument list
    js/background.js:1209 (anonymous function)

  4. Uncaught (in promise) [object Object]
    js/chunk-vendors.cb8df399.js:7 (anonymous function)

The project is an empty setup with vue cli 4, including vuex and eslint.
In development mode the popup doesn't display anything, while the build files will display the helloworld component in the popup.

Error Yarn run serve

After run:
$ vue create .
$ vue add browser-extension

$ yarn run serve
Error:

> vue-cli-service build --mode development --watch
⠇  Bui 98% after emitting SizeLimitsPlugin
                              
ERROR  Failed to compile with 1 errors                                                                                                                                                        error  Unexpected string in JSON at position 723

p/s: package.json

{
  "name": "extension_init",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "serve": "vue-cli-service build --mode development --watch",
    "build": "vue-cli-service build",
    "lint": "vue-cli-service lint",
    "test:unit": "vue-cli-service test:unit"
  },
  "dependencies": {
    "core-js": "^2.6.5",
    "register-service-worker": "^1.6.2",
    "vue": "^2.6.10",
    "vue-router": "^3.0.3",
    "vuex": "^3.0.1",
    "webextension-polyfill": "^0.3.0"
  },
  "devDependencies": {
    "@vue/cli-plugin-babel": "^3.9.0",
    "@vue/cli-plugin-eslint": "^3.9.0",
    "@vue/cli-plugin-pwa": "^3.9.0",
    "@vue/cli-plugin-unit-mocha": "^3.9.0",
    "@vue/cli-service": "^3.9.0",
    "@vue/test-utils": "1.0.0-beta.29",
    "babel-eslint": "^10.0.1",
    "chai": "^4.1.2",
    "eslint": "^5.16.0",
    "eslint-plugin-vue": "^5.0.0",
    "imports-loader": "^0.8.0",
    "vue-cli-plugin-browser-extension": "^0.15.1",
    "vue-template-compiler": "^2.6.10"
  }
}

Could you fix this?
Thank you.

Plugin doesn't work in vue cli 3 modern mode

From vue cli 3 docs, about modern mode:

With Babel we are able to leverage all the newest language features in ES2015+, but that also means we have to ship transpiled and polyfilled bundles in order to support older browsers.

I think this feature is quite useful for development of browser extensions, since we can use there the latest es6 features without fear to break something. Moreover, we can get smaller bundle size and better browser performance.

Expected behaviour

Following vue cli 3 command should work:

vue-cli-service build --modern

What is actually happening?

When I install browser-extension plugin the command above fails.

Error output

ERROR  TypeError: Cannot read property '0' of undefined
TypeError: Cannot read property '0' of undefined
    at /home/kryvonos_v/projects/hello-world/node_modules/vue-cli-plugin-browser-extension/index.js:112:14
    at Object.tap (/home/kryvonos_v/projects/hello-world/node_modules/webpack-chain/src/Plugin.js:24:24)
    at /home/kryvonos_v/projects/hello-world/node_modules/vue-cli-plugin-browser-extension/index.js:111:34
    at /home/kryvonos_v/projects/hello-world/node_modules/@vue/cli-service/lib/Service.js:242:40
    at Array.forEach (<anonymous>)
    at Service.resolveChainableWebpackConfig (/home/kryvonos_v/projects/hello-world/node_modules/@vue/cli-service/lib/Service.js:242:26)
    at PluginAPI.resolveChainableWebpackConfig (/home/kryvonos_v/projects/hello-world/node_modules/@vue/cli-service/lib/PluginAPI.js:151:25)
    at module.exports (/home/kryvonos_v/projects/hello-world/node_modules/@vue/cli-service/lib/commands/build/resolveAppConfig.js:2:22)
    at build (/home/kryvonos_v/projects/hello-world/node_modules/@vue/cli-service/lib/commands/build/index.js:146:50)
    at /home/kryvonos_v/projects/hello-world/node_modules/@vue/cli-service/lib/commands/build/index.js:58:15
    at Service.run (/home/kryvonos_v/projects/hello-world/node_modules/@vue/cli-service/lib/Service.js:236:12)
    at Object.<anonymous> (/home/kryvonos_v/projects/hello-world/node_modules/@vue/cli-service/bin/vue-cli-service.js:37:9)
    at Module._compile (internal/modules/cjs/loader.js:777:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:788:10)
    at Module.load (internal/modules/cjs/loader.js:643:32)
    at Function.Module._load (internal/modules/cjs/loader.js:556:12)

Add Installing Vue-Router and Vuex Options In Prompts

I believe some relatively small-scale projects would not require Vue-Router or Vuex for popup and options pages. It could be great to add some options, which ask users whether to install Vue-Router or Vuex for popup or options (or both) pages, in installing prompts. This could help developers to decrease the total size of extension if the project does not need those unnecessary plugins.

Content and Background Scripts are not executing in dev mode

I've installed the plugin (v0.22.5) on the fresh setup of Vue CLI and the serve command builds the files successfully. The extension loads and displays
[ WER: Connected to Extension Hot Reloader ] but code in content-script or background is not being executed.
Surprisingly, when I build the extension and load it, everything works fine! Something to do it Extension Hot Reloader?

Remove option for browser extension polyfill

Proposal
Since the community has taken some steps to make this a more browser agnostic extension tool, I want to kill the option for including the polyfill and just always include it (and use the auto-include polyfill). For the users who want to make chrome only extensions, that is still possible as the polyfill doesn't remove or disable the chrome object.

Benefit
This will simplify the docs, templates, and initial options as everything can be written consistently. While it does increase the file size of the end distributable (20.5kb unminified), in the presence of the large iconigraphy, Vue as a framework, and other libraries being included this should not be the main focus point of where to trim a few kbs. If after all that, someone needs to trim it down and doesn't want the polyfill, it is now removable since it has been added to the webpack chain.

vue.config.js

module.exports = {
  chainWebpack(config) {
    config.plugins.delete('provide-webextension-polyfill');
    config.module.rules.delete('provide-webextension-polyfill');
  }
}

Implement some lessons learned from webextension-toolbox

I like the way this repo solves some of the single pipeline for cross-browser challenges. For example:

  • Create an output per browser
  • Use an ENV var to specify which browser is the target for a single build, and make a convenience build job to iterate over each vendor.
  • Exposing which browser is being built in process.env so that developers can do specific things per target, and let tree-shaking and dead code deletion optimizations take over
  • Allowing for tagging manifest keys as for specific browser (vendor) targets: __chrome|opera__key,
    • I think I would prefer inverting the targets so that it becomes more readable which
      it actually is: description__chrome|opera__
    • Could use the WebextensionPlugin if I don't invert the vendor and key syntax.
  • Conditional inclusion of the browser polyfill to further reduce bundle size in browsers that don't need it

Remove vuex and vue router from scaffold templates

Probably shouldn't have been so opinionated on this one, and will resolve the issues from #18 . Would be good to have an example repo with links in the README to show how those (and other base options) would fit into the ecosystem.

how to support common chunk (vendor) for background/popup/content/pages

The google extension has multiple content entries and customization pages, it also has a popup and background script. So the output size is too large, I want to split chunks to reduce size of the bundle script, then I adjust vue.config.js:

configureWebpack: {
    optimization: {
      splitChunks: {
        cacheGroups: {
          vendors: {
            test: /[\\/]node_modules[\\/]/,
            name: 'vendors',
            chunks: 'all'
          }
        }
      }
    }
  },
  pages: {
    'popup/popup': {
      entry: 'src/popup/popup.js',
      title: 'Shop Eden',
      chunks: ['vendors', 'popup/popup']
    }
 }

Then the pages, popup scripts is ok, but the background and content scripts doesn't work, How to support split chunks feature for all scripts? (only chainWebpack?)

yarn build --mode=staging doesn't work

yarn build --mode=staging produces an incomplete background.js file in the zipped artifact.

yarn build --mode=staging

$ yarn build --mode=staging
yarn run v1.19.2
$ vue-cli-service build --mode=staging

⠙  Building for staging...[WER-W1] function(obj) {
obj || (obj = {});
var __t, __p = '';
with (obj) {
__p += 'Warning, Extension Reloader Plugin was not enabled! It runs only on webpack --mode=development (v4 or more) or with NODE_ENV=development (lower versions)';

}
return __p
}.
Visit https://github.com/rubenspgcavalcante/webpack-extension-reloader/wiki/General-Information#WER-W1 for complete details

⠸  Building for staging... WARN  No key.pem file found. This is fine for dev, however you may have problems publishing without one
⠴  Building for staging...

 WARNING  Compiled with 3 warnings                                                                11:47:57 AM

 warning

asset size limit: The following asset(s) exceed the recommended size limit (244 KiB).
This can impact web performance.
Assets:
  js/chunk-vendors.js (2.14 MiB)
  ../artifacts/extension-v1.3.18-staging.zip (794 KiB)

 warning

entrypoint size limit: The following entrypoint(s) combined asset size exceeds the recommended limit (244 KiB). This can impact web performance.
Entrypoints:
  popup (2.27 MiB)
      css/chunk-vendors.css
      js/chunk-vendors.js
      css/chunk-common.css
      js/chunk-common.js
      css/popup.css
      js/popup.js
  options (2.26 MiB)
      css/chunk-vendors.css
      js/chunk-vendors.js
      css/chunk-common.css
      js/chunk-common.js
      css/options.css
      js/options.js
  standalone (2.3 MiB)
      css/chunk-vendors.css
      js/chunk-vendors.js
      css/chunk-common.css
      js/chunk-common.js
      css/standalone.css
      js/standalone.js
  background (2.26 MiB)
      css/chunk-vendors.css
      js/chunk-vendors.js
      css/chunk-common.css
      js/chunk-common.js
      js/background.js
  content_scripts/content (2.26 MiB)
      css/chunk-vendors.css
      js/chunk-vendors.js
      css/chunk-common.css
      js/chunk-common.js
      js/content_scripts/content.js
  console (2.26 MiB)
      css/chunk-vendors.css
      js/chunk-vendors.js
      css/chunk-common.css
      js/chunk-common.js
      js/console.js


 warning

webpack performance recommendations:
You can limit the size of your bundles by using import() or require.ensure to lazy load some parts of your application.
For more info visit https://webpack.js.org/guides/code-splitting/

  File                                  Size               Gzipped

  dist/js/chunk-vendors.js              2190.61 KiB        601.70 KiB
  dist/EBML.js                          237.93 KiB         54.33 KiB
  dist/js/chunk-common.js               71.10 KiB          19.42 KiB
  dist/js/standalone.js                 45.53 KiB          14.01 KiB
  dist/js/popup.js                      18.61 KiB          6.54 KiB
  dist/js/background.js                 17.24 KiB          6.86 KiB
  dist/js/options.js                    11.44 KiB          4.64 KiB
  dist/js/console.js                    10.11 KiB          4.04 KiB
  dist/js/content_scripts/content.js    8.91 KiB           3.61 KiB
  dist/css/chunk-vendors.css            36.43 KiB          7.18 KiB
  dist/css/chunk-common.css             3.63 KiB           1.17 KiB
  dist/css/standalone.css               3.13 KiB           1.04 KiB
  dist/css/popup.css                    1.01 KiB           0.44 KiB
  dist/css/options.css                  0.50 KiB           0.26 KiB

  Images and other types of assets omitted.

 DONE  Build complete. The dist directory is ready to be deployed.
 INFO  Check out deployment instructions at https://cli.vuejs.org/guide/deployment.html

vue.config.js

	pluginOptions: {
		browserExtension: {
			modesToZip: ['production', 'staging'],
			components: {
				background: true,
				popup: true,
				options: true,
				contentScripts: true,
				standalone: true,
			},
			componentOptions: {
				background: {
					entry: 'src/background.js',
				},
				contentScripts: {
					entries: {
						'content_scripts/content': 'src/content_scripts/content.js',
						console: 'src/content_scripts/console.js',
					},
				},
			},
		},
	},

Content script naming consistency

Mixed use of underscores and dashes. Is this intentional? /content_scripts/content-script.js

What about renaming content/content.js?

RFC: Should we pre-create an « icons » folder?

I don't see it anymore in template, is there a reason for that?
Would not be a good move to pre-create an icons folder like it's done here ?

I think it would be nice to pre-create it, because it will prevent some errors about not existing icon when loading extension into browser. 👍

Thanks for your time

Add new cli-service command instead of modifying existing.

I have a web project where I use VueCLI and now want to develop a supporting chrome extension. I want to reuse the Vue components in extension and so I need to add this plugin under the same setup. The current plugin modifies the default entry files and thus my default setup stops building. Do we have a workaround where we add new cli-service command instead of making changes in default settings?

So scripts in package.json can be something like this:

"extension:build": "vue-cli-service extension-build",
"extension:serve": "vue-cli-service extension-build --mode development --watch",

The vue-cli-plugin-electron-builder does something like this without touching existing commands.

Failed to mount component: template or render function not defined.

Really weird, this was working fine last night, and now all of a sudden i rerun and get this with the error with popup.js -> App.vue ->router-view, in my devtools inspector
Failed to mount component: template or render function not defined.

Looks like it loads the code because the PageIndex mounted gets called, but it fails to render the template, bewildered by this

Override Tab, Bookmarks, History Support

I created a local branch for override support, would be good to integrate this in


  if (options.components.override) {
    api.render('./template/override', { name, ...options })

    pkg.vue.pages['override/override'] = {
      entry: 'src/override/override.js',
      title: 'Override'
    }
  }
 <%_ if (options.components.override) { -%>
  "chrome_url_overrides": {
      "<%- options.components.overrideOption || 'newtab' %>": "override/override.html"
    }
  <%_
  } -%>

content_security_policy unsafe-eval

I'm trying to edit the content_security_policy but I see that this plugin is was setting its own, only during development, with unsafe-eval, I guess for the purposes of HMR or sourcemap eval?

Is is currently possible to set a custom content_security_policy in such a way that unsafe-eval is removed in production?

Thanks!

Webpack running twice? Consistently getting error about port in use.

EDIT: Clicked enter too early, didn't add a description.

Hi, i'm having an issue with getting the npm run serve with the live reload server to work.

Whenever I run npm run serve i'm consistently getting:

events.js:183
      throw er; // Unhandled 'error' event
      ^

Error: listen EADDRINUSE :::9090

The only way to remediate i've been able to remediate this issue was:

  1. Comment out the line which contains webpackConfig.plugins.push(new ChromeExtensionReloader({ entries })) in the vue-cli-plugin-browser-extension/index.js file.
  2. Run npm run serve
  3. Cancel the process.
  4. Uncomment out the changes I made in step 1.
  5. Run npm run serve

Some more info:

  • Node version: v8.11.3
  • NPM version: 5.6.0
  • OS: macOS High Sierra 10.13.6
  • Project Dependencies and versions:
  "dependencies": {
    "vue": "^2.5.17",
    "vue-router": "^3.0.1",
    "vuex": "^3.0.1"
  },
  "devDependencies": {
    "@vue/cli-plugin-babel": "^3.0.0",
    "@vue/cli-plugin-eslint": "^3.0.0",
    "@vue/cli-service": "^3.0.0",
    "@vue/eslint-config-airbnb": "^3.0.0",
    "vue-cli-plugin-browser-extension": "^0.11.0",
    "vue-template-compiler": "^2.5.17"
  },

I've added a console.trace() into the vue-cli-plugin-browser-extension/index.js file, inside the api.configureWebpack function and the outputs i'm getting (in order), are the following:

Output 1:

⠋  Building for development...
[object Object]
    at api.configureWebpack (/Users/kory/Publift/publift-chrome-extension/node_modules/vue-cli-plugin-browser-extension/index.js:35:13)
    at webpackRawConfigFns.forEach.fn (/Users/kory/Publift/publift-chrome-extension/node_modules/@vue/cli-service/lib/Service.js:227:21)
    at Array.forEach (<anonymous>)
    at Service.resolveWebpackConfig (/Users/kory/Publift/publift-chrome-extension/node_modules/@vue/cli-service/lib/Service.js:224:30)
    at PluginAPI.resolveWebpackConfig (/Users/kory/Publift/publift-chrome-extension/node_modules/@vue/cli-service/lib/PluginAPI.js:115:25)
    at module.exports (/Users/kory/Publift/publift-chrome-extension/node_modules/@vue/cli-service/lib/commands/build/resolveAppConfig.js:34:25)
    at build (/Users/kory/Publift/publift-chrome-extension/node_modules/@vue/cli-service/lib/commands/build/index.js:124:50)
    at api.registerCommand (/Users/kory/Publift/publift-chrome-extension/node_modules/@vue/cli-service/lib/commands/build/index.js:72:13)
    at Service.run (/Users/kory/Publift/publift-chrome-extension/node_modules/@vue/cli-service/lib/Service.js:207:12)
    at Object.<anonymous> (/Users/kory/Publift/publift-chrome-extension/node_modules/@vue/cli-service/bin/vue-cli-service.js:22:9)
    at Module._compile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)
    at Function.Module.runMain (module.js:693:10)

Output 2

⠴  Building for development...
[object Object]
    at api.configureWebpack (/Users/kory/Publift/publift-chrome-extension/node_modules/vue-cli-plugin-browser-extension/index.js:35:13)
    at webpackRawConfigFns.forEach.fn (/Users/kory/Publift/publift-chrome-extension/node_modules/@vue/cli-service/lib/Service.js:227:21)
    at Array.forEach (<anonymous>)
    at Service.resolveWebpackConfig (/Users/kory/Publift/publift-chrome-extension/node_modules/@vue/cli-service/lib/Service.js:224:30)
    at Object.<anonymous> (/Users/kory/Publift/publift-chrome-extension/node_modules/@vue/cli-service/webpack.config.js:12:26)
    at Module._compile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)
    at Module.require (module.js:596:17)
    at require (internal/module.js:11:18)
    at Object.exports.resolve (/Users/kory/Publift/publift-chrome-extension/node_modules/eslint-import-resolver-webpack/index.js:69:25)
    at v2 (/Users/kory/Publift/publift-chrome-extension/node_modules/eslint-module-utils/resolve.js:94:23)
    at withResolver (/Users/kory/Publift/publift-chrome-extension/node_modules/eslint-module-utils/resolve.js:99:16)
    at fullResolve (/Users/kory/Publift/publift-chrome-extension/node_modules/eslint-module-utils/resolve.js:116:22)

Let me know if there is anything else I can provide, would really like to get this working.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.