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
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/*"],
}