-
Notifications
You must be signed in to change notification settings - Fork 30
/
Copy pathbuild-identity-iframe.js
85 lines (76 loc) · 1.93 KB
/
build-identity-iframe.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const webpackTemplate = require('html-webpack-template');
const webpack = require('webpack');
const baseHref = '/muse/identity/';
const babelConfig = {
'presets': [
[
'@babel/env', {
'targets': {
'ie': 11,
'chrome': 27,
'firefox': 30,
'safari': 7,
'opera': 23
},
'loose': true,
'exclude': [
'transform-regenerator'
]
}
],
'@babel/react',
'@babel/flow'
],
'plugins': [
[ 'transform-inline-environment-variables' ],
'babel-plugin-transform-es2015-modules-commonjs',
[ '@babel/plugin-syntax-dynamic-import', { 'loose': true } ],
[ '@babel/plugin-proposal-decorators', { 'loose': true, 'legacy': true } ],
[ '@babel/plugin-proposal-class-properties', { 'loose': true } ],
[ '@babel/plugin-transform-for-of', { 'assumeArray': true } ],
[ '@babel/plugin-transform-runtime', { 'corejs': false, 'helpers': true, 'regenerator': false } ]
]
};
const webpackConfig = {
mode: 'production',
entry: path.resolve(__dirname, 'iframes/identity/identity.js'),
output: {
path: path.resolve(__dirname, 'dist/identity'),
filename: 'identity.js'
},
plugins: [ new HtmlWebpackPlugin({
inject: false,
template: webpackTemplate,
title: 'Identity',
showErrors: false,
baseHref
}) ],
module: {
rules: [ {
test: /\.js$/,
loader: 'babel-loader',
options: babelConfig
} ]
}
};
const compiler = webpack(webpackConfig);
compiler.run((err, stats) => {
if (err) {
console.error(err);
}
if (stats.hasErrors()) {
console.log(stats.toString({
colors: true,
stats: 'errors-only'
}));
} else {
console.log(stats.toString({
colors: true,
outputPath: true
}));
console.log()
console.log('Identity iframe build succeed');
}
});