JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 17984
  • Score
    100M100P100Q138518F
  • License MIT

WebExtension Target for Webpack 4. Supports code-splitting with native dynamic import.

Package Exports

  • webpack-target-webextension

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (webpack-target-webextension) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

webpack-target-webextension

npm-version

WebExtension Target for Webpack 4. Supports code-splitting with native dynamic import.

You can use the neutrino-webextension preset directly which uses this library.

The code is based on the official web target.

Installation

yarn

yarn add -D webpack-target-webextension

npm

npm install -D webpack-target-webextension

Usage

You might also need to remove the @babel/plugin-syntax-dynamic-import plugin.

// webpack.config.js

const path = require('path')
const WebExtensionTarget = require('')

// Optional webpack node config
const nodeConfig = {}

module.exports = {
  node: nodeConfig
  // Need to set manually as the default values of these fields rely on `web` target.
  // See https://v4.webpack.js.org/configuration/resolve/#resolvemainfields
  resolve: {
    mainFields: ['browser', 'module', 'main'],
    aliasFields: ['browser']
  },
  output: {
    globalObject: 'window'
    // set it relative to extension root
    publicPath: '/assets/',
  },
  target: WebExtensionTarget(nodeConfig)
}
// manifest.json

{
  // make sure chunks are accessible
  "web_accessible_resources": ["assets/*"],
}