Repository navigation
Expand file tree
/
Copy pathwebpack.config.js
More file actions
69 lines (66 loc) · 2.55 KB
/
Copy pathwebpack.config.js
File metadata and controls
69 lines (66 loc) · 2.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
const path = require('path');
const webpack = require('webpack');
const CopyPlugin = require('copy-webpack-plugin');
const { LicenseWebpackPlugin } = require('license-webpack-plugin');
module.exports = (env = {}, argv = {}) => {
const browser = env.browser || process.env.BROWSER || 'chrome';
const manifestFile = `src/manifest.${browser === 'chrome' ? 'chrome' : 'firefox'}.json`;
const isProd = argv.mode === 'production';
// Dev builds get a per-build timestamp the extension logs on load, so you can
// confirm the running code is the one start.js just built. Production builds
// use the static version (no timestamp) to keep store builds reproducible.
const buildId = process.env.HTML2MD_BUILD_ID
|| (isProd ? require('./package.json').version : new Date().toISOString());
return {
entry: {
'background': './src/background.js',
'devtools/devtools': './src/devtools/devtools.js',
'devtools/sidepanel': './src/devtools/sidepanel.js'
},
devtool: isProd ? false : 'source-map',
output: {
path: path.resolve(__dirname, 'dist'),
filename: '[name].js',
clean: true
},
plugins: [
new webpack.DefinePlugin({
__BUILD_ID__: JSON.stringify(buildId),
__DEV__: JSON.stringify(!isProd),
}),
new LicenseWebpackPlugin({
outputFilename: 'THIRD_PARTY_LICENSES.txt',
// Graph discovery misses packages resolved via an `exports` "import"
// condition (webpack prefixes their identifier with `javascript/esm|`,
// which the plugin misparses), so list every runtime dep explicitly.
additionalModules: Object.keys(require('./package.json').dependencies).map((name) => ({
name,
directory: path.join(__dirname, 'node_modules', name),
})),
}),
new CopyPlugin({
patterns: [
{
from: manifestFile,
to: 'manifest.json',
// package.json is the single source of truth for the version.
transform: (content) => JSON.stringify(
{ ...JSON.parse(content), version: require('./package.json').version },
null, 2
),
},
{ from: 'src/devtools/devtools.html', to: 'devtools/devtools.html' },
{ from: 'src/devtools/sidepanel.html', to: 'devtools/sidepanel.html' },
{ from: 'src/devtools/sidepanel.css', to: 'devtools/sidepanel.css' },
{ from: 'src/icons', to: 'icons' }
]
})
],
resolve: {
fallback: {
"buffer": false,
"url": false
}
}
};
};