blob: bd5ea2ab0d6fda2d4243673e0d36b7150f8fb7c4 [file] [log] [blame]
Michael Landoefa037d2017-02-19 12:57:33 +02001var webpack = require('webpack');
2var path = require('path');
3
4var PATHS = {
Einav Weiss Keidarf2c47232018-05-30 18:12:02 +03005 SRC: path.resolve(__dirname, 'src/main/webapp'),
6 TARGET: path.resolve(__dirname, 'dist')
Michael Landoefa037d2017-02-19 12:57:33 +02007};
8
Einav Weiss Keidarf2c47232018-05-30 18:12:02 +03009module.exports = (env, argv) => {
10 let devmode = argv.mode && argv.mode === 'development';
11 let entry = [];
12 if (devmode) {
13 entry.push(path.resolve(PATHS.SRC, 'lib/main.jsx'));
14 } else {
15 entry.push(
16 path.resolve(PATHS.SRC, 'lib/ecomp/asdc/sequencer/Sequencer.jsx')
17 );
18 }
Michael Landoefa037d2017-02-19 12:57:33 +020019
Einav Weiss Keidarf2c47232018-05-30 18:12:02 +030020 let config = {
21 entry: entry,
22 performance: { hints: false },
23 output: {
24 path: PATHS.TARGET,
25 filename: 'index.js',
26 libraryTarget: 'umd'
27 },
28 resolve: {
29 extensions: ['.js', '.jsx']
30 },
31 devtool: 'eval-source-map',
32 module: {
33 rules: [
34 {
35 test: /\.(js|jsx)$/,
36 loader: 'eslint-loader',
37 include: [/src/],
38 enforce: 'pre'
svishnev10c74ee2018-01-22 08:43:04 +020039 },
Einav Weiss Keidarf2c47232018-05-30 18:12:02 +030040 {
41 test: /\.(js|jsx)$/,
42 loader: 'babel-loader',
43 include: path.join(PATHS.SRC, 'lib')
44 },
45 {
46 test: /\.(css)$/,
47 use: [{ loader: 'style-loader' }, { loader: 'css-loader' }]
48 },
49 {
50 test: /\.(png|woff|woff2|eot|ttf|otf)$/,
51 loader: 'url-loader?limit=100000'
52 },
53 {
54 test: /\.scss$/,
55 include: path.join(PATHS.SRC, 'res'),
56 loaders: ['style-loader', 'css-loader', 'sass-loader']
57 },
58 {
59 test: /\.html$/,
60 include: path.join(PATHS.SRC, 'lib'),
61 loaders: ['raw-loader']
62 },
63 {
64 test: /\.svg$/,
65 loader: 'svg-sprite-loader',
66 options: {
67 symbolId: '[name]_[hash]',
68 extract: false
69 }
70 }
71 ]
72 },
73 externals: devmode
74 ? {}
75 : {
76 'd3-zoom': 'd3-zoom',
77 'd3-selection': 'd3-selection',
78 'lodash/merge': 'lodash/merge',
79 'lodash/template': 'lodash/template',
80 react: 'react',
81 'react-dnd': 'react-dnd',
82 'react-dnd-html5-backend': 'react-dnd-html5-backend',
83 'react-dom': 'react-dom',
84 'react-redux': 'react-redux',
85 'react-select': 'react-select',
86 redux: 'redux',
87 'prop-types': 'prop-types'
88 },
89 devServer: {
90 port: 4096,
91 quiet: false,
92 contentBase: 'src/main/webapp',
93 proxy: {
94 '/services/*': {
95 target: 'http://localhost:38080/asdc-sequencer',
96 secure: false
97 }
svishnev10c74ee2018-01-22 08:43:04 +020098 }
Einav Weiss Keidarf2c47232018-05-30 18:12:02 +030099 },
100 plugins: devmode
101 ? [
102 new webpack.DefinePlugin({
103 DEBUG: devmode === true,
104 DEV: devmode === true
105 }),
106 new webpack.HotModuleReplacementPlugin(),
107 new webpack.LoaderOptionsPlugin({
108 options: {
109 eslint: {
110 failOnWarning: false,
111 failOnError: false,
112 configFile: 'eslintrc.json'
113 },
114 context: '/'
115 }
116 })
117 ]
118 : [
119 new webpack.DefinePlugin({
120 DEBUG: devmode === true,
121 DEV: devmode === true
122 }),
123 new webpack.LoaderOptionsPlugin({
124 options: {
125 eslint: {
126 failOnWarning: false,
127 failOnError: false,
128 configFile: 'eslintrc.json'
129 },
130 context: '/'
131 }
132 })
133 ]
134 };
Michael Landoefa037d2017-02-19 12:57:33 +0200135
Einav Weiss Keidarf2c47232018-05-30 18:12:02 +0300136 return config;
137};