Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update to web-ext-plugin version 2.x.x (#271)
Required addional compiler options for ts-node to be able to handle ESM modules, which web-ext and web-ext-plugin now use. Also Webpack configuration needed to be split for ESLint to still be able to use it. See webpack/webpack-cli#2458 for details regarding ts-node and ESM.
- Loading branch information
Showing
6 changed files
with
1,560 additions
and
1,330 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
import path from 'path'; | ||
import type { Configuration, RuleSetUseItem } from 'webpack'; | ||
import MiniCssExtractPlugin from 'mini-css-extract-plugin'; | ||
|
||
import { BrowserFamily } from '../src/manifest.json'; | ||
|
||
const rootDir = path.resolve(__dirname, '..'); | ||
export const srcDir = path.resolve(rootDir, 'src'); | ||
|
||
enum WebpackMode { | ||
PROD = 'production', | ||
DEVEL = 'development', | ||
} | ||
|
||
const mode = process.env.MODE === WebpackMode.DEVEL ? WebpackMode.DEVEL : WebpackMode.PROD; | ||
const devtool = mode === WebpackMode.DEVEL ? 'source-map' : 'nosources-source-map'; | ||
|
||
export const targetBrowser = process.env.TARGET_BROWSER as BrowserFamily || BrowserFamily.MOZILLA; | ||
|
||
const tsLoader: RuleSetUseItem = { | ||
loader: 'ts-loader', | ||
options: { | ||
configFile: path.resolve(__dirname, 'tsconfig.json'), | ||
}, | ||
}; | ||
|
||
export const commonConfiguration: Configuration = { | ||
mode, | ||
devtool, | ||
stats: 'errors-only', | ||
output: { | ||
path: path.resolve(rootDir, 'dist', targetBrowser, 'src'), | ||
}, | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.css$/i, | ||
include: srcDir, | ||
use: [ MiniCssExtractPlugin.loader, 'css-loader' ], | ||
}, | ||
{ | ||
test: /\.tsx?$/, | ||
include: srcDir, | ||
use: [ tsLoader ], | ||
}, | ||
{ | ||
test: /\.json$/, | ||
include: srcDir, | ||
use: [ tsLoader ], | ||
}, | ||
{ | ||
test: /\.png$/, | ||
include: srcDir, | ||
type: 'asset/inline', // base64 encoded | ||
}, | ||
{ | ||
test: /\.svg$/, | ||
include: srcDir, | ||
type: 'asset/inline', // base64 encoded | ||
}, | ||
{ | ||
test: /\.md$/, | ||
include: rootDir, | ||
type: 'asset/source', // as file content | ||
}, | ||
], | ||
}, | ||
resolve: { | ||
modules: [ path.resolve(rootDir, 'node_modules') ], | ||
extensions: [ '.ts', '.tsx', '.js', '.jsx', '.css', '.json', '.png', '.svg', '.md' ], | ||
alias: { | ||
'@assets': path.resolve(srcDir, 'assets'), | ||
'@background': path.resolve(srcDir, 'background'), | ||
'@commons': path.resolve(srcDir, 'commons'), | ||
'@frontend': path.resolve(srcDir, 'frontend'), | ||
}, | ||
}, | ||
}; | ||
|
||
export default commonConfiguration; |
Oops, something went wrong.