blob: 4dfa1a85b69b6c4757010af091f16b5b3c7c1ecf [file] [log] [blame]
Michael Landoefa037d2017-02-19 12:57:33 +02001var webpack = require('webpack');
2var path = require('path');
3
4var PATHS = {
5 SRC: path.resolve(__dirname, 'src/main/webapp'),
6 TARGET: path.resolve(__dirname, 'dist')
7};
8
9var devmode = (process.env.npm_lifecycle_event === 'start');
10
11var entry = [];
12if (devmode) {
Michael Landoefa037d2017-02-19 12:57:33 +020013 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
18var config = {
19 entry: entry,
20 output: {
21 path: PATHS.TARGET,
22 filename: 'index.js',
23 libraryTarget: 'umd'
24 },
25 resolve: {
svishnev10c74ee2018-01-22 08:43:04 +020026 extensions: ['.js', '.jsx']
Michael Landoefa037d2017-02-19 12:57:33 +020027 },
28 devtool: 'eval-source-map',
29 module: {
svishnev10c74ee2018-01-22 08:43:04 +020030 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 },
svishnev10c74ee2018-01-22 08:43:04 +020049 {
50 test: /\.svg$/,
51 loader: 'svg-sprite-loader?' + JSON.stringify({
52 name: '[name]_[hash]',
53 prefixize: true
54 })
55 }
56 ]
Michael Landoefa037d2017-02-19 12:57:33 +020057 },
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 }
svishnev10c74ee2018-01-22 08:43:04 +020079 },
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 Landoefa037d2017-02-19 12:57:33 +020097};
98
99module.exports = config;