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: { |
svishnev | 10c74ee | 2018-01-22 08:43:04 +0200 | [diff] [blame^] | 27 | extensions: ['.js', '.jsx'] |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 28 | }, |
| 29 | devtool: 'eval-source-map', |
| 30 | module: { |
svishnev | 10c74ee | 2018-01-22 08:43:04 +0200 | [diff] [blame^] | 31 | rules: [ |
| 32 | {test: /\.(js|jsx)$/, loader: 'eslint-loader', exclude: [/node_modules/], enforce: 'pre'}, |
| 33 | {test: /\.(js|jsx)$/, loader: 'babel-loader', |
| 34 | exclude: /node_modules/, |
| 35 | include: path.join(PATHS.SRC, 'lib')}, |
| 36 | {test: /\.(css)$/, use: [ |
| 37 | {loader: 'style-loader'}, |
| 38 | {loader: 'css-loader'}]}, |
| 39 | {test: /\.(png|woff|woff2|eot|ttf|otf)$/, loader: 'url-loader?limit=100000'}, |
| 40 | { |
| 41 | test: /\.scss$/, |
| 42 | include: path.join(PATHS.SRC, 'res'), |
| 43 | loaders: ['style-loader', 'css-loader', 'sass-loader'] |
| 44 | }, |
| 45 | { |
| 46 | test: /\.html$/, |
| 47 | include: path.join(PATHS.SRC, 'lib'), |
| 48 | loaders: ['raw-loader'] |
| 49 | }, |
| 50 | { |
| 51 | test: /\.json$/, |
| 52 | include: path.join(PATHS.SRC, 'lib'), |
| 53 | loaders: ['json-loader'] |
| 54 | }, |
| 55 | { |
| 56 | test: /\.svg$/, |
| 57 | loader: 'svg-sprite-loader?' + JSON.stringify({ |
| 58 | name: '[name]_[hash]', |
| 59 | prefixize: true |
| 60 | }) |
| 61 | } |
| 62 | ] |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 63 | }, |
| 64 | externals: (devmode ? {} : { |
| 65 | 'd3': 'd3', |
| 66 | 'lodash': 'lodash', |
| 67 | 'react': 'react', |
| 68 | 'react-dnd': 'react-dnd', |
| 69 | 'react-dnd-html5-backend': 'react-dnd-html5-backend', |
| 70 | 'react-dom': 'react-dom', |
| 71 | 'react-redux': 'react-redux', |
| 72 | 'react-select': 'react-select', |
| 73 | 'redux': 'redux' |
| 74 | }), |
| 75 | devServer: { |
| 76 | port: 4096, |
| 77 | quiet: false, |
| 78 | contentBase: 'src/main/webapp', |
| 79 | proxy: { |
| 80 | '/services/*': { |
| 81 | target: 'http://localhost:38080/asdc-sequencer', |
| 82 | secure: false |
| 83 | } |
| 84 | } |
svishnev | 10c74ee | 2018-01-22 08:43:04 +0200 | [diff] [blame^] | 85 | }, |
| 86 | plugins: [ |
| 87 | new webpack.DefinePlugin({ |
| 88 | DEV: true, |
| 89 | DEBUG: true |
| 90 | }), |
| 91 | new webpack.HotModuleReplacementPlugin(), |
| 92 | new webpack.LoaderOptionsPlugin({ |
| 93 | options: { |
| 94 | eslint: { |
| 95 | failOnWarning: false, |
| 96 | failOnError: false, |
| 97 | configFile: 'eslintrc.json' |
| 98 | }, |
| 99 | context: '/' |
| 100 | } |
| 101 | }) |
| 102 | ] |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 103 | }; |
| 104 | |
| 105 | module.exports = config; |