const path = require('path');
const CleanWebpackPlugin = require('clean-webpack-plugin');
const { DefinePlugin, HotModuleReplacementPlugin } = require('webpack');
-
+const HtmlWebpackPlugin = require('html-webpack-plugin');
const devConfig = require('./tools/getDevConfig');
const proxyServer = require('./proxy-server');
-const fs = require('fs');
-let devPort = process.env.PORT || devConfig.port;
-let publicPath = 'http://localhost:' + devPort + '/onboarding/';
+const devPort = process.env.PORT || devConfig.port;
+const publicPath = 'http://localhost:' + devPort + '/onboarding/';
module.exports = (env, argv) => {
- let DEV = argv.mode && argv.mode === 'development';
- let language = null;
+ const IS_DEV = argv.mode && argv.mode === 'development';
+ let language;
if (
env === undefined ||
env.language === undefined ||
console.log('Setting language to "' + env.language + '".');
}
- var webpackConfig = {
+ const webpackConfig = {
entry: {
'punch-outs': ['sdc-app/punch-outs.js']
},
cache: true,
- devtool: DEV ? 'eval-source-map' : undefined,
+ devtool: IS_DEV ? 'eval-source-map' : undefined,
performance: { hints: false },
resolve: {
modules: [path.resolve('.'), path.join(__dirname, 'node_modules')],
},
output: {
path: path.join(__dirname, 'dist'),
- publicPath: DEV ? publicPath : '/onboarding/',
- filename: DEV ? '[name].js' : '[name]_' + language + '.js'
+ publicPath: IS_DEV ? publicPath : './',
+ filename: IS_DEV ? '[name].js' : '[name]_' + language + '.js'
},
module: {
rules: [
],
include: [
/resources/,
- path.join(
- __dirname,
- 'node_modules/dox-sequence-diagram-ui/'
- ),
+ path.join(__dirname, IS_DEV ? '../dox-sequence-diagram-ui/' : 'node_modules/dox-sequence-diagram-ui/'),
path.join(__dirname, 'node_modules/react-datepicker/'),
path.join(__dirname, 'node_modules/react-select/'),
- path.join(__dirname, 'node_modules/sdc-ui/')
+ path.join(__dirname, 'node_modules/onap-ui-common/'),
+ path.join(__dirname, 'node_modules/react-checkbox-tree/')
]
},
{
__dirname,
'node_modules/dox-sequence-diagram-ui/'
),
- path.join(__dirname, 'node_modules/sdc-ui/')
+ path.join(__dirname, 'node_modules/onap-ui-common/')
]
},
{
}
]
},
- plugins: DEV
+ plugins: IS_DEV
? [
new CleanWebpackPlugin(['dist'], { watch: false }),
new DefinePlugin({
- DEBUG: DEV === true,
- DEV: DEV === true
+ DEBUG: true,
+ DEV: true
}),
new HotModuleReplacementPlugin()
]
: [
new DefinePlugin({
- DEBUG: DEV === true,
- DEV: DEV === true
+ DEBUG: false,
+ DEV: false,
+ }),
+ new HtmlWebpackPlugin({
+ filename: 'index.html',
+ template: __dirname + '/src/index.html'
})
]
};
- if (DEV) {
+ if (IS_DEV) {
webpackConfig.output.globalObject = 'this';
webpackConfig.entry['punch-outs'].push('react-hot-loader/patch');
webpackConfig.entry['punch-outs'].push(
before: proxyServer
};
}
- console.log('Running build for : ' + argv.mode);
+ console.log('Running build for: ' + argv.mode);
return webpackConfig;
};