-
Notifications
You must be signed in to change notification settings - Fork 212
/
Copy pathwebpack.config.snippet.js
64 lines (57 loc) · 1.39 KB
/
webpack.config.snippet.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
var fs = require('fs');
var path = require('path');
var webpack = require('webpack');
var defaults = require('./defaults');
var webpackConfig = require('./webpack.config.js');
var outputPath = path.resolve(__dirname, 'dist');
var defaultsPlugin = new webpack.DefinePlugin(defaults);
var snippetConfig = {
name: 'snippet',
entry: {
'rollbar.snippet': './src/browser/bundles/rollbar.snippet.js'
},
output: {
path: outputPath,
filename: '[name].js'
},
plugins: [defaultsPlugin],
module: {
rules: [
{
enforce: 'pre',
test: /\.js$/,
loader: 'eslint-loader',
exclude: [/node_modules/, /vendor/],
options: {
failOnError: true,
configFile: path.resolve(__dirname, '.eslintrc')
}
},
{
test: /\.js$/,
loader: 'strict-loader',
exclude: [/node_modules/, /vendor/]
}
],
}
};
function buildConfig() {
var hash
try {
hash = JSON.parse(
fs.readFileSync(path.join(
webpackConfig.find(({entry}) => entry.rollbar).output.path, 'manifest.json',
)),
)['rollbar.js'].integrity;
} catch (error) {} // eslint-disable-line no-empty
return {
...snippetConfig,
plugins: [
...snippetConfig.plugins,
new webpack.DefinePlugin({
__DEFAULT_ROLLBARJS_HASH__: JSON.stringify(hash),
}),
],
}
}
module.exports = buildConfig;