Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 1 | var webpack = require('webpack'); |
| 2 | var path = require('path'); |
| 3 | |
| 4 | var PATHS = { |
| 5 | SRC: path.resolve(__dirname, 'src/main/webapp'), |
| 6 | TARGET: path.resolve(__dirname, 'dist') |
| 7 | }; |
| 8 | |
| 9 | var devmode = (process.env.npm_lifecycle_event === 'start'); |
| 10 | |
| 11 | var entry = []; |
| 12 | if (devmode) { |
| 13 | entry.push('babel-polyfill'); |
| 14 | entry.push(path.resolve(PATHS.SRC, 'lib/main.jsx')); |
| 15 | } else { |
| 16 | entry.push(path.resolve(PATHS.SRC, 'lib/ecomp/asdc/sequencer/Sequencer.jsx')); |
| 17 | } |
| 18 | |
| 19 | var config = { |
| 20 | entry: entry, |
| 21 | output: { |
| 22 | path: PATHS.TARGET, |
| 23 | filename: 'index.js', |
| 24 | libraryTarget: 'umd' |
| 25 | }, |
| 26 | resolve: { |
| 27 | extensions: ['', '.js', '.jsx'] |
| 28 | }, |
| 29 | eslint: { |
| 30 | failOnWarning: false, |
avigaffa | a0858ef | 2017-09-12 11:46:01 +0300 | [diff] [blame] | 31 | failOnError: false, |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 32 | configFile: 'eslintrc.json' |
| 33 | }, |
| 34 | devtool: 'eval-source-map', |
| 35 | module: { |
| 36 | preLoaders: [{ |
| 37 | test: /\.(js|jsx)?$/, |
| 38 | loader: 'eslint-loader', |
| 39 | exclude: /node_modules/ |
| 40 | }], |
| 41 | loaders: [{ |
| 42 | test: /\.(js|jsx)$/, |
| 43 | include: path.join(PATHS.SRC, 'lib'), |
| 44 | loader: 'babel-loader', |
| 45 | exclude: /node_modules/, |
| 46 | query: { |
| 47 | presets: ['es2015', 'react'] |
| 48 | } |
| 49 | }, { |
| 50 | test: /\.css$/, |
| 51 | loaders: ['style', 'css'] |
| 52 | }, { |
| 53 | test: /\.(png|woff|woff2|eot|ttf|otf)$/, |
| 54 | loader: 'url-loader?limit=100000' |
| 55 | }, { |
| 56 | test: /\.scss$/, |
| 57 | include: path.join(PATHS.SRC, 'res'), |
| 58 | loaders: ['style', 'css', 'sass'] |
| 59 | }, { |
| 60 | test: /\.html$/, |
| 61 | include: path.join(PATHS.SRC, 'lib'), |
| 62 | loaders: ['raw'] |
| 63 | }, { |
| 64 | test: /\.json$/, |
| 65 | include: path.join(PATHS.SRC, 'lib'), |
| 66 | loaders: ['json'] |
| 67 | }, { |
| 68 | test: /\.svg$/, |
| 69 | loader: 'svg-sprite?' + JSON.stringify({ |
| 70 | name: '[name]_[hash]', |
| 71 | prefixize: true |
| 72 | }) |
| 73 | }] |
| 74 | }, |
| 75 | externals: (devmode ? {} : { |
| 76 | 'd3': 'd3', |
| 77 | 'lodash': 'lodash', |
| 78 | 'react': 'react', |
| 79 | 'react-dnd': 'react-dnd', |
| 80 | 'react-dnd-html5-backend': 'react-dnd-html5-backend', |
| 81 | 'react-dom': 'react-dom', |
| 82 | 'react-redux': 'react-redux', |
| 83 | 'react-select': 'react-select', |
| 84 | 'redux': 'redux' |
| 85 | }), |
| 86 | devServer: { |
| 87 | port: 4096, |
| 88 | quiet: false, |
| 89 | contentBase: 'src/main/webapp', |
| 90 | proxy: { |
| 91 | '/services/*': { |
| 92 | target: 'http://localhost:38080/asdc-sequencer', |
| 93 | secure: false |
| 94 | } |
| 95 | } |
| 96 | } |
| 97 | }; |
| 98 | |
| 99 | module.exports = config; |