Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame^] | 1 | /*- |
| 2 | * ============LICENSE_START======================================================= |
| 3 | * SDC |
| 4 | * ================================================================================ |
| 5 | * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. |
| 6 | * ================================================================================ |
| 7 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 8 | * you may not use this file except in compliance with the License. |
| 9 | * You may obtain a copy of the License at |
| 10 | * |
| 11 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 12 | * |
| 13 | * Unless required by applicable law or agreed to in writing, software |
| 14 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 16 | * See the License for the specific language governing permissions and |
| 17 | * limitations under the License. |
| 18 | * ============LICENSE_END========================================================= |
| 19 | */ |
| 20 | |
| 21 | 'use strict'; |
| 22 | |
| 23 | var path = require('path'); |
| 24 | var webpack = require('webpack'); |
| 25 | |
| 26 | var localDevConfig = {}; |
| 27 | try { |
| 28 | localDevConfig = require('./devConfig'); |
| 29 | } catch(e) {} |
| 30 | var devConfig = Object.assign({}, require('./devConfig.defaults'), localDevConfig); |
| 31 | var devPort = process.env.PORT || devConfig.port; |
| 32 | var latestProgress = 0; |
| 33 | |
| 34 | module.exports = { |
| 35 | devtool: 'eval-source-map', |
| 36 | entry: { |
| 37 | bundle: [ |
| 38 | 'sdc-app/sdc.app.jsx', |
| 39 | `webpack-dev-server/client?http://localhost:${devPort}`, |
| 40 | 'webpack/hot/only-dev-server' |
| 41 | ], |
| 42 | 'punch-outs': [ |
| 43 | 'sdc-app/punch-outs.js', |
| 44 | `webpack-dev-server/client?http://localhost:${devPort}`, |
| 45 | 'webpack/hot/only-dev-server' |
| 46 | ], |
| 47 | 'heat-validation': [ |
| 48 | 'sdc-app/heatValidation.app.jsx', |
| 49 | `webpack-dev-server/client?http://localhost:${devPort}`, |
| 50 | 'webpack/hot/only-dev-server' |
| 51 | ] |
| 52 | }, |
| 53 | resolve: { |
| 54 | root: [path.resolve('.')], |
| 55 | alias: { |
| 56 | i18nJson: 'nfvo-utils/i18n/locale.json', |
| 57 | 'nfvo-utils': 'src/nfvo-utils', |
| 58 | 'nfvo-components': 'src/nfvo-components', |
| 59 | 'sdc-app': 'src/sdc-app' |
| 60 | } |
| 61 | }, |
| 62 | output: { |
| 63 | path: path.join(__dirname, 'dist/dev'), |
| 64 | publicPath: `http://localhost:${devPort}/onboarding/`, |
| 65 | filename: '[name].js' |
| 66 | }, |
| 67 | devServer: { |
| 68 | port: devPort, |
| 69 | historyApiFallback: true, |
| 70 | publicPath: `http://localhost:${devPort}/onboarding/`, |
| 71 | contentBase: path.join(__dirname, 'dist/dev'), |
| 72 | hot: true, |
| 73 | progress: true, |
| 74 | inline: true, |
| 75 | debug: true, |
| 76 | stats: { |
| 77 | colors: true |
| 78 | } |
| 79 | }, |
| 80 | module: { |
| 81 | preLoaders: [ |
| 82 | {test: /\.(js|jsx)$/, loader: 'source-map-loader', exclude: /node_modules/} |
| 83 | ], |
| 84 | loaders: [ |
| 85 | {test: /\.(js|jsx)$/, loaders: ['react-hot', 'babel-loader', 'eslint-loader'], exclude: /node_modules/}, |
| 86 | {test: /\.(css|scss)$/, loaders: ['style', 'css?sourceMap', 'sass?sourceMap']}, |
| 87 | |
| 88 | // required for font icons |
| 89 | {test: /\.(woff|woff2)(\?.*)?$/, loader: 'url-loader?limit=16384&mimetype=application/font-woff' }, |
| 90 | {test: /\.(ttf|eot|otf)(\?.*)?$/, loader: 'file-loader' }, |
| 91 | {test: /\.(png|jpg|svg)(\?.*)?$/, loader: 'url-loader?limit=16384'}, |
| 92 | |
| 93 | {test: /\.json$/, loaders: ['json']}, |
| 94 | {test: /\.html$/, loaders: ['html']} |
| 95 | ] |
| 96 | }, |
| 97 | eslint: { |
| 98 | configFile: './.eslintrc', |
| 99 | emitError: true, |
| 100 | emitWarning: true |
| 101 | }, |
| 102 | plugins: [ |
| 103 | new webpack.DefinePlugin({ |
| 104 | DEV: true, |
| 105 | DEBUG: true |
| 106 | }), |
| 107 | new webpack.HotModuleReplacementPlugin(), |
| 108 | new webpack.ProgressPlugin(function (percentage, msg) { |
| 109 | if (percentage == 0) { |
| 110 | latestProgress = 0; |
| 111 | console.log(); //new line |
| 112 | } |
| 113 | var progressVal = (percentage * 100).toFixed(0); |
| 114 | if (progressVal > latestProgress) { |
| 115 | latestProgress = progressVal |
| 116 | //process.stdout.clearLine(); |
| 117 | process.stdout.write(msg + ' ' + progressVal + '%\r'); |
| 118 | } |
| 119 | }) |
| 120 | ] |
| 121 | |
| 122 | }; |