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