Code Monkey home page Code Monkey logo

webextension-toolbox / webextension-toolbox Goto Github PK

View Code? Open in Web Editor NEW
678.0 14.0 67.0 1.79 MB

Small CLI toolbox for cross-browser WebExtension development

Home Page: https://npmjs.com/package/@webextension-toolbox/webextension-toolbox

License: MIT License

JavaScript 3.60% TypeScript 95.19% Makefile 1.22%
webextension chrome-extension opera-extension edge-extension firefox-extension webpack auto webextension-toolbox cli-toolbox firefox

webextension-toolbox's Introduction

WebExtension Toolbox

npm version Node.js CI license

Small cli toolbox for creating cross-browser WebExtensions.

If you want to get started quickly check out the yeoman generator for this project.

Browser Support

Official

These browsers are tested through github actions

  • Edge (edge)
  • Firefox (firefox)
  • Chrome (chrome)
  • Safari (safari)
  • Opera (opera)

Unofficial

These browsers will compile but are not tested

  • Internet Explorer (ie)
  • iOS Safari (ios_saf)
  • Opera Mini (op_mini)
  • Android Browser (android)
  • Blackberry Browser (bb)
  • Opera Mobile (op_mob)
  • Chrome for Android (and_chr)
  • Firefox for Android (and_ff)
  • Internet Explorer Mobile (ie_mob)
  • UC Browser (and_uc)
  • Samsung Internet (samsung)
  • QQ Browser (and_qq)
  • Baidu Browser (baidu)
  • KaiOS (kaios)

Features

Packing

The build task creates specific bundles for:

  • Firefox (.xpi)
  • Opera (.crx)

all other bundles are .zip files

Manifest validation

Validates your manifest.json while compiling.

You can skip this by adding --validateManifest to your build or dev command.

Manifest defaults

Uses default fields (name, version, description) from your package.json

Typescript Support

Native typescript support (but not enforced!) (see section How do I use Typescript?)

Manifest vendor keys

Allows you to define vendor specific manifest keys.

Example

manifest.json

"name": "my-extension",
"__chrome__key": "yourchromekey",
"__chrome|opera__key2": "yourblinkkey"

If the vendor is chrome it compiles to:

"name": "my-extension",
"key": "yourchromekey",
"key2": "yourblinkkey"

If the vendor is opera it compiles to:

"name": "my-extension",
"key2": "yourblinkkey"

else it compiles to:

"name": "my-extension"

Polyfill

The WebExtension specification is currently supported on Chrome, Firefox, Edge (Chromium) and Safari (Safari Web Extension’s Browser Compatibility).

This toolbox no longer provides any polyfills for cross-browser support. If you need polyfills e.g. between 'browser' and 'chrome', we recommend detecting the browser during the build time using process.env.VENDOR.

This toolbox comes with babel-preset-env. Feel free add custom configuration if you need any custom polyfills.

Usage

Install

Globally

$ npm install -g @webextension-toolbox/webextension-toolbox

Locally

$ npm install -D @webextension-toolbox/webextension-toolbox

Development

  • Compiles the extension via webpack to dist/<vendor>.
  • Watches all extension files and recompiles on demand.
  • Reloads extension or extension page as soon something changed.
  • Sets process.env.NODE_ENV to development.
  • Sets process.env.VENDOR to the current vendor.

Syntax

$ webextension-toolbox dev <vendor> [..options]

Examples

$ webextension-toolbox dev --help
$ webextension-toolbox dev chrome
$ webextension-toolbox dev firefox
$ webextension-toolbox dev edge
$ webextension-toolbox dev safari

Build

  • Compile extension via webpack to dist/<vendor>.
  • Minifies extension Code.
  • Sets process.env.NODE_ENV to production.
  • Sets process.env.VENDOR to the current vendor.
  • Packs extension to packages.

Syntax

Building

Usage: build [options] <vendor>

Compiles extension for production

Options:
  --swc                                Use SWC instead of Babel
  -c, --config [config]                specify config file path
  -s, --src [src]                      specify source directory (default: "app")
  -t, --target [target]                specify target directory (default: "dist/[vendor]")
  -d, --devtool [string | false]       controls if and how source maps are generated (default: "cheap-source-map")
  --vendor-version [vendorVersion]     last supported vendor (default: current)
  --copy-ignore [copyIgnore...]        Do not copy the files in this list, glob pattern
  --compile-ignore [compileIgnore...]  Do not compile the files in this list, glob pattern
  --no-manifest-validation             Skip Manifest Validation
  --save                               Save config to .webextensiontoolboxrc
  --verbose                            print messages at the beginning and end of incremental build
  --no-minimize                        disables code minification
  -h, --help                           display help for command

Developing

Usage: dev [options] <vendor>

Compiles extension in devmode

Arguments:
  vendor                                The Vendor to compile

Options:
  --swc                                Use SWC instead of Babel
  -c, --config [config]                specify config file path
  -s, --src [src]                      specify source directory (default: "app")
  -t, --target [target]                specify target directory (default: "dist/[vendor]")
  -d, --devtool [string | false]       controls if and how source maps are generated (default: "cheap-source-map")
  --vendor-version [vendorVersion]     last supported vendor (default: current)
  --copy-ignore [copyIgnore...]        Do not copy the files in this list, glob pattern
  --compile-ignore [compileIgnore...]  Do not compile the files in this list, glob pattern
  --no-manifest-validation             Skip Manifest Validation
  --save                               Save config to .webextensiontoolboxrc
  --verbose                            print messages at the beginning and end of incremental build
  --no-auto-reload                     Do not inject auto reload scripts into background pages or service workers
  -p, --port [port]                    Define the port for the websocket development server (default: "35729")
  --dev-server [devServer]             use webpack dev server to serve bundled files (default: false)
  -h, --help                           display help for command

.webextensiontoolboxrc

This file is used to configure the WebExtension Toolbox without cli options. You can generate it by running webextension-toolbox <options> --save command. This will take your current cli options and save them to .webextensiontoolboxrc. You can then run webextension-toolbox without any options

Customizing webpack config

In order to extend the usage of webpack, you can define a function that extends its config through a file you define through the usage of the -c option in your project root.

module.exports = {
  webpack: (config, { dev, vendor }) => {
    // Perform customizations to webpack config

    // Important: return the modified config
    return config;
  },
};

As WebExtension Toolbox uses webpack’s devtool feature under the hood, you can also customize the desired devtool with the --devtool argument.

For example, if you have problems with source maps on Firefox, you can try the following command:

webextension-toolbox build firefox --devtool=inline-cheap-source-map

Please see Issue #58 for more information on this

FAQ

What is the difference to web-ext?

If want to develop browser extensions for Firefox only web-ext might be a better fit for you, since it supports extension signing, better manifest validation and auto mounting.

Nevertheless if you want to develop cross browser extensions using

  • the same development experience in every browser
  • a single codebase
  • custom webpack configuration

webextension-toolbox might be your tool of choice.

How do I use React?

  1. npm install @babel/preset-react --save-dev
  2. Create a .babelrc file next to your package.json file and insert the following contents:
{
  "presets": [
    "@babel/preset-react"
  ]
}

How do I use Typescript?

  1. npm install typescript --save-dev
  2. Run tsc --init or manually add a tsconfig.json file to your project root

What is SWC?

SWC (stands for Speedy Web Compiler) is a super-fast TypeScript / JavaScript compiler written in Rust. It's an alternative to Babel. For more informaiton see: https://github.com/swc-project/swc

License

Copyright 2018-2023 Henrik Wenz

This project is free software released under the MIT license.

webextension-toolbox's People

Contributors

azure-pipelines[bot] avatar balcsida avatar dependabot-preview[bot] avatar dependabot[bot] avatar dotproto avatar erictrinh avatar fapdash avatar fedcomp avatar greenkeeper[bot] avatar handtrix avatar here-nerd avatar imgbotapp avatar jimmorrison723 avatar joelspadin avatar nurodev avatar pbek avatar phothiabea avatar renovate-bot avatar rthaut avatar tm1000 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  avatar  avatar  avatar  avatar  avatar

webextension-toolbox's Issues

Add a compile done marker to dev output

Expected Behavior

It would be very helpful to add markers to the webextension-toolbox dev ... output to mark the start and end of the output for one compilation, similar to what is done by webpack-cli with the --info-verbosity=verbose option: https://github.com/webpack/webpack-cli/blob/master/bin/cli.js#L274

This would allow for tools that analyze the output of webextension-toolbox to identify when webpack recompiles the extension, and to parse warnings and errors from the latest compilation.

Current Behavior

Errors and warnings are printed at the end of the output. An external tool cannot know when one compilation is done until the next one starts.

Steps to Reproduce (for bugs)

  1. Create an extension using ts-loader and tslint-loader as described in #93 (comment)
  2. Add a tslint.json to the root of the project:
{
    "extends": "tslint:recommended"
}
  1. Add a .ts file with some code that tslint will flag. A statement that doesn't end with a semicolon will work.
  2. Run webextension-toolbox dev chrome.

Context

I use Visual Studio Code as my IDE, and it can be configured to parse the output of a build task for warnings and errors. When parsing the output of a task that watches for changes and automatically recompiles (such as webpack --watch or webextension-toolbox dev ...), it needs to match some text at the start and end of each re-compilation to identify the latest output.

See https://github.com/eamodio/vscode-tsl-problem-matcher/blob/master/package.json#L111 for an example configuration to parse the output of webpack --watch for warnings from tslint.

For now I have been adding the following plugin to my build:

export class VSCodeOutputWebpackPlugin {
    public apply(compiler) {
        // Match output of https://github.com/webpack/webpack-cli/blob/master/bin/cli.js
        // so that $*-webpack-watch problem matchers work.
        compiler.hooks.done.tap('WebpackInfo', stats => {
            if (stats.hasErrors() || stats.hasWarnings()) {
                console.error(`\nCompilation ${compiler.name} starting…\n`);
                console.error(stats.toString('errors-warnings'));
                console.error(`\nCompilation ${compiler.name} finished\n`);
            }
        });
    }
}

This usually works, but it doubles any warnings/errors in the output. It would be nice if WebExtension Toolbox had a verbose option like "webpack --watch --info-verbosity=verbose" or marked the start/end of its output by default.

Your Environment

Tech Version
webextension-toolbox 3.0.0
node 12.3.1
OS Windows 10 build 17763
vscode 1.34.0

Files copied in webextension-toolbox-config.js are not included in .zip package

Expected Behavior

If you have a webextension-toolbox-config.js that uses copy-webpack-plugin to copy files into the build directory, those files should get included in the .zip package.

Current Behavior

The ZipPlugin added at webpack-config.js line 183 runs before any copy-webpack-plugin defined in webextension-toolbox-config.js, and it misses any copied files.

Steps to Reproduce (for bugs)

Install React:

npm i -S react

Set up a webpack configuration that defines React as an external library and copies it into the build directory.

// webextension-toolbox-config.js
const CopyPlugin = require('copy-webpack-plugin');

module.exports = {
    webpack: (config, { dev }) => {
        config.externals = {
            "react": "React",
        };

        const mode = dev ? 'development' : 'production.min';
        config.plugins.push(new CopyPlugin([
            {
                from: `../node_modules/react/umd/react.${mode}.js`,
                to: 'scripts/react/react.js',
                cache: true
            },
        ]));
        return config;
    }
};

Build the extension:

webextension-toolbox build chrome

react.js will be copied to /dist/chrome/scripts/react, but it won't be included in packages/*.chrome.zip.

Context

I have been able to work around this by adding the following to my webextension-toolbox-config.js to move ZipPlugin to the end of the plugins list:

module.exports = {
    webpack: (config, { dev }) => {
        ...
        for (let i = 0; i < config.plugins.length; i++) {
            if (config.plugins[i] instanceof ZipPlugin) {
                let plugins = config.plugins.splice(i, 1);
                config.plugins.push(...plugins);
                break;
            }
        }
        return config;
    }
};

I could also only make React an external library in dev builds because I'm mainly doing this to speed up builds, but that would require making changes to how my options page links scripts based on the build mode, so I'd like to avoid that.

Your Environment

Tech Version
webextension-toolbox 3.0.0
node 11.6.0
OS Windows 10 build 17763

typescript (.ts) entry point support

Hi,

I would like to use typescript together with webextension-generator/webextension-toolbox. I have tried to import a typescript file and works fine, but I cannot provide a typescript file as an entry point.

Expected Behavior

A typescript file e.g. main.ts (found in ./app/scripts/main.ts) should be a compiled to ./dist/chrome/scripts/popup.js

It would be nice to support typescript files as entry points.

Current Behavior

A typescript file from app/scripts/main.ts cannot be used as an entry point because won't get compiled to a .js file.

Steps to Reproduce (for bugs)

  1. add main.ts to scripts folder
  2. npm run dev chrome
  3. expect dist/chrome/scripts/main.js

Context

Your Environment

Tech Version
webextension-toolbox 2.0
node 10.10.0
OS ubuntu-18.04
browser chrome
etc

webextension polyfill not included

Hey, thanks for this tool; exactly what I need!

The compiler doesn't seem to be including the webextension polyfill. I'm getting browser is not defined errors in the console.

Support for SCSS and TS.

Great toolbox. Thanks for the hardwork.
Would it be possible to add your own loaders to the webpack config?
Need to add scss-loader and or ts-loader.

Thanks again.

Expose copy files ignore

Currently, the webpack copy plugin has a pre-defined set of file extensions to ignore. Exposing this would be super helpful to let people blacklist file types from being copied over that they do not want πŸ‘
Or an alternative is an option to toggle/disable copying all other files in your app directory to the build directory πŸ˜„

manifest.json enviroment keys

Is there anyway to do it?
I want add

"content_security_policy": "script-src 'self' 'unsafe-eval'; object-src 'self'"

to eval source maps in chrome dev console.

But I want to remove this line in production build.

Shorthand vendorVersion does not work

The shorthand argument for --vendorVersion, -vv, does not work because commander.js does not support two character shorthand.
This should be easily fixed by changing it to one character πŸ™‚

Workaround: use the full argument --vendorVersion

Discovered while working on #57, #107

FireFox extension signing

Hi
I am aware that your documentation states that if extension signing is a requirement then you recommend using web-ext.

Can you please provide best solution to sign the FF extension while still using your toolbox?

expose babel config

Expected Behavior

I would like to be able to configure babel-loader. Today the boilerplate this project offers is tightly coupled to react (includes react specific config for babel-loader). It would be nice to have an easier way to configure this (maybe do babel config in package.json?).

Current Behavior

No easy way to configure babel. webextension-toolbox is tightly coupled to react

Context

I would like to use other libraries with JSX like preact, therefore I need to be able to change babel-loader config.

Your Environment

Not relevant

Incompatable with webext-redux on Firefox

Expected Behavior

webextension-toolbox and webext-redux should work together in Firefox.

Current Behavior

Content script hangs in Firefox. No useful message or stack trace in the console.

Steps to Reproduce (for bugs)

  1. Checkout example repository at: https://github.com/ChrisLMerrill/CrossBrowserWebextensionReactReduxExample
  2. npm install
  3. build for Firefox with "webextension-toolbox build firefox"
  4. Install extension from dist/firefox folder
  5. Look in the console for a page. You should see "Content script is running", but in Firefox this message does not appear because the content script is hung by the combination of webextension-toolbox and webext-redux. In Chrome and Edge, the message appears and the content script operates as expected.

Context

My trivial example built with webextension-toolbox ran fine before adding webext-redux. Cannot use webextension-toolbox and webext-redux together. This makes me sad :(

The author of webext-redux has been unable to reproduce the problem when webextension-toolbox is not part of the equation.
tshaddix/webext-redux#193

So this appears to be a conflict between the two, rather than a bug isolated to either one. My JS skills are a bit limited and I've exceeded my ability to to debug this. I'm hoping you can collaborate with tshaddix to find the conflict.

Your Environment

Tech Version
javascript packages listed in package.json in example
node 10.15.1
OS Windows 10
browser Firefox 65.0.2
etc

cant' build firefox extension

thankyou for cool tool!

but firefox extension can't build.
firefox says There was an error during installation: Extension is invalid

it's error logs

[./app/scripts/background.js] ./app/scripts/background.js 231 bytes {4} [built]
[./app/scripts/contentscript.js] ./app/scripts/contentscript.js 43 bytes {3} [built]
[./app/scripts/devtools.js] ./app/scripts/devtools.js 47 bytes {2} [built]
[./app/scripts/options.js] ./app/scripts/options.js 36 bytes {1} [built]
[./app/scripts/popup.js] ./app/scripts/popup.js 34 bytes {0} [built]
Running web extension from /Users/m0a/repo/github.com/m0a-mystudy/my-web-extension/dist/firefox
Use --verbose or open Tools > Web Developer > Browser Console to see logging
(node:57807) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): WebExtError: installTemporaryAddon: Error: unknownError: Could not install add-on at '/Users/m0a/repo/github.com/m0a-mystudy/my-web-extension/dist/firefox': Error: Extension is invalid
(node:57807) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

code is here.

QUESTION :: How to Run Development Locally

Context

I'm new to front-end / web extension development. I would like to develop my WebExtension locally. I'm unsure how local development is done with this package. build is working fine with Load Temporary Add-on... in FireFox, but is constantly refreshing the add-on the development process for extension developers? I was hoping there would be a live-reload, and I could just open my browser to see live changes. I'm not sure what the use of dev is for.

I tried to connect to localhost:35729 within my browser, but I'm only getting the message: Upgrade Required. I believe this websocket is only for listening to code changes. πŸ˜…

Any insight on the development process using this tool would be much appreciated. Thanks!

Smoke test is not working on Windows

Checking the logs for Windows on Azure DevOps, you can quickly notice that only npm install is performed but there are no output for npm test.
This should be fixed, every test should be performed on Windows as well.

Add config path argument

Would be a nice added CLI option to be able to manually specify the path to your webextension-toolbox.config.js. Since that's a bit of a mouthful it would be handy if I could rename it to something like webext.config.js or similar and be able to pass something like --config or -c to specify a config path πŸ˜„

Transforming manifest vendor keys only works on first level

Vendor prefixed manifest keys only gets replaced on the first level of the manifest.json file.
E.g:

{
  "manifest_version": 2,
  "browser_action": {
    "__firefox__theme_icons": [
      {
        "light": "icons/icon16-light.png",
        "dark": "icons/icon16.png",
        "size": 16
      },
      {
        "light": "icons/icon32-light.png",
        "dark": "icons/icon32.png",
        "size": 32
      }
    ]
  },

This gets copied as-is.

Native VueJS support?

A nice quality of life improvement

I can see that currently there is native support for React which is great! πŸ‘Œ
Is there any plans to add native VueJS support in the future? I know it can be done already by using a custom webextension-toolbox-config.js file, but having native support in the future would be nice πŸ˜„

autoReload not working

Executing npm run dev chrome won't trigger the copy of autoReload.js at the root directory of the extension

webpack.DefinePlugin usage

Hi
I would like to inject global js variables into the extension.

So i edit webextension-toolbox-config.js like so:

module.exports = {
webpack: (config, { dev, vendor }) => {
config.plugins.push( new webpack.DefinePlugin({ GLOBAL_VAR: "value" }) );
return config;
}
}

However, GLOBAL_VAR is not defined in background context nor in popup

How can we achieve this using the toolbox?

Typescript support

Would it be hard or at all possible to add the support for Typescript?

Extension autoreload is broken on Chrome

Expected Behavior

On file change, the browser should reload the extension and the current page

Current Behavior

On file change, the browser window is reloaded, but you have to manually reload your extension

cannot pass vendorVersion option to webextension-toolbox

Expected Behavior

when calling this package like this: webextension-toolbox dev chrome --vendorVersion=71 I expect the vendorVersion to be passed further to src/compile script. I think or it seems that it doesn't

I did a bit of research and wrote a bit more here

Passing vendorVersion has an influence on the babel-loader more specifically on babel/preset-env and how the code gets transpiled. This is a core feature and doesn't work correctly in my opinion.

WebSocket Connection Failure

built the example bookmarkit extension for chrome and manually loaded to chrome. It shows an error message:

WebSocket connection to 'ws://127.0.0.1:35729/' failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED

Expected Behavior

no error message

no

Current Behavior

Steps to Reproduce (for bugs)

Context

Your Environment

Tech Version
webextension-toolbox
node
OS
browser
etc

Add Edge autoreload support

Expected Behavior

Autoreload should work in MS-Edge.

Current Behavior

In MS-Edge websocket connections to localhost are blocked by design.

Steps to Reproduce (for bugs)

  1. Run webextension-toolbox dev edge
  2. Open background console

Your Environment

Tech Version
webextension-toolbox 1.0.0-beta.6
node v9.1.0
OS Windows 10
browser Edge

Related Issues

Use web-ext

I suggest leaving the manifest validation and packing to pre-existing tools offered by Mozilla (web-ext does both)

Also I'd rather see https://github.com/mozilla/webextension-polyfill added to manifest.json directly instead, e.g. ec960f0 β€” but perhaps it isn't a big deal, really, since it can't be automatically added to options.html this way.

Building exits prematurely when webextension-toolbox.js exists

Expected Behavior

If a webextension-toolbox.js file is present in the root directory of my project, with the code snippet provided by the readme, the webextention should build with all configurations for webpack made by the toolbox itself in addition to the rules, plugins, ect. pushed into their respective arrays by the code inside the snippets webpack() function

// This file is not going through babel transformation.
// So, we write it in vanilla JS
// (But you could use ES2015 features supported by your Node.js version)
module.exports = {
  webpack: (config, { dev, vendor }) => {
    // Perform customizations to webpack config

    // Important: return the modified config
    return config
  }
}

Current Behavior

The build processes starts and ends prematurely on success, throwing no errors, but not starting webpack; generating no files.

PS C:\Users\li6hu3\WebstormProjects\Shopping_Cart_Analyzer> yarn run build firefox
yarn run v1.7.0
$ webextension-toolbox build firefox
Done in 1.01s.
PS C:\Users\li6hu3\WebstormProjects\Shopping_Cart_Analyzer> yarn run dev firefox
yarn run v1.7.0
$ webextension-toolbox dev firefox
Done in 1.00s.
PS C:\Users\li6hu3\WebstormProjects\Shopping_Cart_Analyzer>

Steps to Reproduce (for bugs)

  1. Generate new scaffold with yo web-extension
  2. add webextension-toolbox.js file to root of project (beside files like package.json)
  3. insert code snippet for the file provided by the README
  4. (optional) push a e.g. webpack rule into config.module.rules (either way, the config should be passed in and out of the function)
  5. build extension in dev or prod e.g. yarn run build chrome

Context

I need to add bootstrap to my extension which means I need to add a style and css loader and additionally wanted to define jQuery as a plugin via webpack.ProvidePlugin for convenience (although not necessary as bootstrap will require popperjs and query on its own)

Your Environment

Tech Version
webextension-toolbox 1.0.0
node 10.2
OS Windows 10 (1709/16299.461)
browser -
etc yarn 1.7.0, powershell

question: next release?

Expected Behavior

Maybe it's time for a new release?

Current Behavior

Current release doesn't allow for configurable webpack config, but that has been fixed in the meantime #31 and #37

Steps to Reproduce (for bugs)

Context

I want to use the latest version to be able to config webpack further

Your Environment

OS: windows 10
webextension-toolbox: 1.0.5
node: 8.9.4

Should we disable minification?

Problem

Some webstores doesn't like it, when extension code is minified.
This makes their review more complex.

Possible solutions

A. Disable minification
C. Enable minification (everything stays the same)
B. Add an cli flag to leave it up to the user (default will be disabled)
D. Add an cli flag to leave it up to the user (default will be enabled)

Related docs

https://webpack.js.org/configuration/optimization/

Open questions

Does tree shaking and dead code elimination still work if minification is disabled? If not can we enable it somehow?

What do you think?

Release new version

Hi everyone,

As Babel 7 stable is out, I think it is time to release a new version of WebExtension Toolbox.
@HaNdTriX was kind enough to provide me an npm publish access but I never ever released anything before. He recommended me to use sindresorhus/np for the release, but I'm still figuring out whether should I bump the minor or the major version (to 2.0.0).

Could you please help me out in this matter?

I am also opening this ticket to push me to make this happen and not to procrastinate anymore on it.

Alter file name of packaged zip file

Hi
How can i change the zip file name that is created after running "npm run build chrome"?
Is it possible by adding a config to webextension-toolbox-config.js?
Thanks

Provide more information when manifest.json fails validation

Expected Behavior

manifest.json passes validation.

Current Behavior

I get this error with no other context:

You need to provide a valid 'manifest.json'

Steps to Reproduce (for bugs)

  1. npm install --save-dev webextension-toolbox
  2. npx webextension-toolbox build firefox

Context

I'm trying to build https://github.com/carlin-q-scott/browser-media-players/tree/webextension-toolbox but my manifest.json is failing validation.

Your Environment

Tech Version
webextension-toolbox 2.0.0
node v8.12.0
OS Windows 10
browser Firefox
terminal environment Powershell v5.1.17134.228

Customizing webpack config problem on Windows

Expected Behavior

When i want to extend usage of Webpack by creating webextension-toolbox.js, it should just work.

Current Behavior

I add webextension-toolbox.js, paste code from readme, and add jquery plugin, i got Windows Srcript Host errors all the time. simetimes 1:1, by default it gives error to dev, vendor, it expects :

Steps to Reproduce (for bugs)

  1. generate extension via generator
  2. create webextension-toolbox.js
  3. yarn add jquery
  4. add code:
module.exports = {
  webpack: (config, { dev, vendor }) => {
    // Perform customizations to webpack config
	config.plugins.push(
	  new webpack.ProvidePlugin({
		  $: 'jquery',
		  jQuery: 'jquery'
	  })
	)
    // Important: return the modified config
    return config
  }
}

Tried different ways for module export, no luck.

Context

Parts of my extension containes jquery, that's why i need it.

Your Environment

Tech Version
webextension-toolbox 1.0.4
node 10.1.0
OS W10
browser
etc

JSX support

Hello,

I'm trying to write a component in JSX but I receive an error:

ERROR in ./app/components/PopupApp.jsx
Module parse failed: Unexpected token (3:24)
You may need an appropriate loader to handle this file type.
| import React from 'react'
| 
| export default props => <h1></h1>

Do you know why it does not support JSX despite the presence of the babel preset "react" in the webpack configuration ?

Debugging with source maps

Thanks so much for the webextension toolbox.

I feel really dumb since I can not for the life of me to get sourcemaps to load in Firefox. The .map files are present but in Firefox they fail to load.

I have managed to get them working in chrome by adding the extension directory as a workspace.

I generated a extension with generator-web-extension and have tried loading it via about:debugging in firefox and web-ext.

I receive the following error.

Source map error: TypeError: NetworkError when attempting to fetch resource.
Resource URL: moz-extension://1cbd74c0-6413-472e-a5f8-10fcf1debb5f/scripts/background.js
Source Map URL: background.js.map[Learn More] (unknown)

I am expecting source maps to load and to be able to set a breakout point in background.js.

Tech Version
webextension-toolbox 1.1.1
node 9.11.1
OS Ubuntu 16.04
browser Firefox 60

Polyfill option is removed from babel-transform-runtime RC4, causing build to break

During the manual testing of #81, building the bookmark-it extension failed because Babel 7-RC4 removed polyfill option from transform-runtime (see babel/babel#8547 for more info on that).

First of all, I would like to fix this issue, it seems that simply removing this configuration option from our side is enough.
Secondly, I will open a separate Issue, so next time npm test will try to build the bookmark-it example extension, so Travis and AppVeyor has greater chance to catch these kind of issues.

Use xip.io for WebSocket connection with Edge

Instead of depending on a workaround that requires user interaction (see #22 for more info), we should bake a workaround into the the tool itself.
As accessing the remote DNS server requires an active internet connection, checking it is a good idea (maybe using is-online npm package)

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.