summaryrefslogtreecommitdiffstats
path: root/dox-sequence-diagram-ui/webpack.config.js
blob: 4dfa1a85b69b6c4757010af091f16b5b3c7c1ecf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
var webpack = require('webpack');
var path = require('path');

var PATHS = {
	SRC: path.resolve(__dirname, 'src/main/webapp'),
	TARGET: path.resolve(__dirname, 'dist')
};

var devmode = (process.env.npm_lifecycle_event === 'start');

var entry = [];
if (devmode) {
	entry.push(path.resolve(PATHS.SRC, 'lib/main.jsx'));
} else {
	entry.push(path.resolve(PATHS.SRC, 'lib/ecomp/asdc/sequencer/Sequencer.jsx'));
}

var config = {
	entry: entry,
	output: {
		path: PATHS.TARGET,
		filename: 'index.js',
		libraryTarget: 'umd'
	},
	resolve: {
		extensions: ['.js', '.jsx']
	},
	devtool: 'eval-source-map',
	module: {
		rules: [
    		{test: /\.(js|jsx)$/, loader: 'eslint-loader', exclude: [/node_modules/], enforce: 'pre'},
            {test: /\.(js|jsx)$/, loader: 'babel-loader',
				exclude: /node_modules/,
				include: path.join(PATHS.SRC, 'lib')},
			{test: /\.(css)$/, use: [
                    {loader: 'style-loader'},
                    {loader: 'css-loader'}]},
			{test: /\.(png|woff|woff2|eot|ttf|otf)$/, loader: 'url-loader?limit=100000'},
            {
                test: /\.scss$/,
                include: path.join(PATHS.SRC, 'res'),
                loaders: ['style-loader', 'css-loader', 'sass-loader']
            },
			{
                test: /\.html$/,
                include: path.join(PATHS.SRC, 'lib'),
                loaders: ['raw-loader']
            },
            {
                test: /\.svg$/,
                loader: 'svg-sprite-loader?' + JSON.stringify({
                    name: '[name]_[hash]',
                    prefixize: true
                })
            }
		]
	},
	externals: (devmode ? {} : {
		'd3': 'd3',
		'lodash': 'lodash',
		'react': 'react',
		'react-dnd': 'react-dnd',
		'react-dnd-html5-backend': 'react-dnd-html5-backend',
		'react-dom': 'react-dom',
		'react-redux': 'react-redux',
		'react-select': 'react-select',
		'redux': 'redux'
	}),
	devServer: {
		port: 4096,
		quiet: false,
		contentBase: 'src/main/webapp',
		proxy: {
			'/services/*': {
				target: 'http://localhost:38080/asdc-sequencer',
				secure: false
			}
		}
	},
    plugins: [
        new webpack.DefinePlugin({
            DEV: true,
            DEBUG: true
        }),
        new webpack.HotModuleReplacementPlugin(),
        new webpack.LoaderOptionsPlugin({
            options: {
                eslint: {
                    failOnWarning: false,
                    failOnError: false,
                    configFile: 'eslintrc.json'
                },
                context: '/'
            }
        })
    ]
};

module.exports = config;