forked from datavisyn/datavisyn-scatterplot-react
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
65 lines (62 loc) · 1.88 KB
/
webpack.config.js
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
const webpack = require('webpack');
const path = require('path');
const pkg = require('./package.json');
const year = (new Date()).getFullYear();
const banner = '/*! ' + (pkg.title || pkg.name) + ' - v' + pkg.version + ' - ' + year + '\n' +
(pkg.homepage ? '* ' + pkg.homepage + '\n' : '') +
'* Copyright (c) ' + year + ' ' + pkg.author.name + ';' +
' Licensed ' + pkg.license + '*/\n';
module.exports = function (env) {
const isProduction = env === 'prod';
const base = {
entry: {
scatterplot: path.resolve(__dirname, 'src/index.tsx')
},
output: {
path: path.resolve(__dirname, 'build'),
publicPath: '',
filename: '[name].js',
libraryTarget: 'umd',
library: ['datavisyn', 'scatterplot']
},
module: {
loaders: [{
test: /\.tsx?$/,
loader: 'awesome-typescript-loader'
}, {
test: /\.scss$/,
loader: 'style-loader!css-loader!sass-loader'
}]
},
resolve: {
extensions: ['.webpack.js', '.web.js', '.js', '.ts', '.tsx'],
modules: [path.resolve(__dirname, 'src'), 'node_modules', path.resolve(__dirname, '../')]
},
externals: {
react: { amd: 'react', root: 'React', commonjs: 'react', commonjs2: 'react' },
'react-dom': { amd: 'react-dom', root: 'ReactDOM', commonjs: 'react-dom', commonjs2: 'react-dom' }
},
plugins: [
new webpack.BannerPlugin({
banner: banner,
raw: true
}),
new webpack.DefinePlugin({
'process.env': {
'NODE_ENV': JSON.stringify(isProduction ? 'production' : 'development')
}
})
],
devServer: {
contentBase: path.resolve(__dirname, 'build'),
proxy: {
'/manhattan*': {
target: 'http://localhost:9000',
secure: false
}
}
},
devtool: isProduction ? 'cheap-module-source-map' : 'source-map'
};
return base;
};