3 const path = require('path');
4 const CleanWebpackPlugin = require('clean-webpack-plugin');
5 const { DefinePlugin, HotModuleReplacementPlugin } = require('webpack');
6 const HtmlWebpackPlugin = require('html-webpack-plugin');
7 const devConfig = require('./tools/getDevConfig');
8 const proxyServer = require('./proxy-server');
10 const devPort = process.env.PORT || devConfig.port;
11 const publicPath = 'http://localhost:' + devPort + '/onboarding/';
13 module.exports = (env, argv) => {
14 const IS_DEV = argv.mode && argv.mode === 'development';
18 env.language === undefined ||
21 console.log('Setting language to default "en".');
24 language = env.language;
25 console.log('Setting language to "' + env.language + '".');
28 const webpackConfig = {
30 'punch-outs': ['sdc-app/punch-outs.js']
33 devtool: IS_DEV ? 'eval-source-map' : undefined,
34 performance: { hints: false },
36 modules: [path.resolve('.'), path.join(__dirname, 'node_modules')],
38 i18nJson: 'nfvo-utils/i18n/' + language + '.json',
39 'nfvo-utils': 'src/nfvo-utils',
40 'nfvo-components': 'src/nfvo-components',
41 'sdc-app': 'src/sdc-app',
42 // TODO - this is needed for heatValidation standalone. Can be deprecated down the line
43 'react-select/dist/': 'node_modules' + '/react-select/dist/'
47 path: path.join(__dirname, 'dist'),
48 publicPath: IS_DEV ? publicPath : './',
49 filename: IS_DEV ? '[name].js' : '[name]_' + language + '.js'
56 include: path.resolve(__dirname, 'src'),
57 use: [{ loader: 'eslint-loader' }]
61 include: path.resolve(__dirname, 'src'),
62 use: [{ loader: 'babel-loader' }]
66 loader: 'source-map-loader',
67 include: path.resolve(__dirname, 'src'),
71 test: /\.(css|scss)$/,
74 loader: 'style-loader'
80 loader: 'sass-loader',
82 output: { path: path.join(__dirname, 'dist') }
88 path.join(__dirname, IS_DEV ? '../dox-sequence-diagram-ui/' : 'node_modules/dox-sequence-diagram-ui/'),
89 path.join(__dirname, 'node_modules/react-datepicker/'),
90 path.join(__dirname, 'node_modules/react-select/'),
91 path.join(__dirname, 'node_modules/onap-ui-common/'),
92 path.join(__dirname, 'node_modules/react-checkbox-tree/')
96 test: /\.(svg)(\?.*)?$/,
100 mimetype: 'image/svg+xml'
105 'node_modules/dox-sequence-diagram-ui/'
107 path.join(__dirname, 'node_modules/onap-ui-common/')
111 test: /\.worker\.js$/,
112 use: { loader: 'worker-loader' }
118 new CleanWebpackPlugin(['dist'], { watch: false }),
123 new HotModuleReplacementPlugin()
130 new HtmlWebpackPlugin({
131 filename: 'index.html',
132 template: __dirname + '/src/index.html'
137 webpackConfig.output.globalObject = 'this';
138 webpackConfig.entry['punch-outs'].push('react-hot-loader/patch');
139 webpackConfig.entry['punch-outs'].push(
140 'webpack-dev-server/client?http://localhost:' + devPort
142 webpackConfig.entry['punch-outs'].push('webpack/hot/only-dev-server');
143 webpackConfig.devServer = {
145 historyApiFallback: true,
146 publicPath: publicPath,
147 contentBase: path.join(__dirname, 'dist'),
152 exclude: [path.join(__dirname, 'node_modules')]
157 console.log('Running build for: ' + argv.mode);
158 return webpackConfig;