forked from subscriptionscore/extension
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.firefox.js
66 lines (62 loc) · 1.63 KB
/
webpack.firefox.js
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
const path = require('path');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const ZipPlugin = require('zip-webpack-plugin');
const commonOptions = require('./webpack.config');
const baseManifest = require('./manifest.json');
const options = {
mode: commonOptions.mode,
optimization: commonOptions.optimization,
entry: commonOptions.entry,
output: {
path: path.join(__dirname, 'build/firefox'),
filename: '[name].bundle.js'
},
module: {
rules: commonOptions.module.rules
},
resolve: {
...commonOptions.resolve,
alias: {
browser: path.resolve(__dirname, 'src/js/browser/firefox')
}
},
plugins: [
...commonOptions.plugins,
new CopyWebpackPlugin([
...commonOptions.copyFiles,
{
from: 'src/manifest.firefox.json',
to: 'manifest.json',
transform: function(content) {
const manifest = {
...baseManifest,
...JSON.parse(content.toString())
};
let name = manifest.name;
if (commonOptions.isDevelopment) {
name = `${name} Dev`;
}
// generates the manifest file using the package.json informations
return Buffer.from(
JSON.stringify({
...manifest,
name
})
);
}
}
]),
...(commonOptions.isDevelopment
? []
: [
new ZipPlugin({
path: '../../releases',
filename: `firefox-latest.zip`
})
])
]
};
if (process.env.NODE_ENV === 'development') {
options.devtool = 'cheap-module-eval-source-map';
}
module.exports = options;