-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
73 lines (70 loc) · 1.85 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
66
67
68
69
70
71
72
73
var path = require('path');
var APP_DIR = path.resolve(__dirname, 'src');
var BUILD_DIR = path.resolve(__dirname, 'lib');
var config = {
entry: APP_DIR + '/line-chart.jsx',
output: {
path: BUILD_DIR,
filename: 'line-chart.js',
library: 'LucifySmallLineChart',
libraryTarget: 'umd'
},
module: {
loaders: [
{
test: /\.scss$/,
loaders: [
require.resolve('style-loader'),
require.resolve('css-loader') + '?modules&importLoaders=2&localIdentName=[name]__[local]___[hash:base64:5]',
require.resolve('postcss-loader'),
require.resolve('sass-loader')
]
},
{
test: /\.(jsx|js)$/,
exclude: /node_modules/,
loader: 'babel-loader',
query: {
presets: ['es2015', 'stage-0', 'react']
}
}
]
},
externals: {
react: {
root: 'React',
commonjs: 'react',
commonjs2: 'react',
amd: 'react'
},
'd3': 'd3',
'lodash': 'lodash'
},
resolve: {
extensions: ['', '.js', '.jsx', '.scss'],
root: [path.join(__dirname, 'lib')],
fallback: [path.join(__dirname, 'node_modules')],
alias: {
react: path.resolve('./node_modules/react'),
'react-dom': path.resolve('./node_modules/react-dom')
}
},
resolveLoader: {
modulesDirectories: ['node_modules'],
fallback: path.join(__dirname, 'node_modules')
},
postcss: [
require('autoprefixer'),
require('postcss-reporter')
],
plugins: [
function() {
this.plugin('done', function(stats) {
if (stats.compilation.errors && stats.compilation.errors.length && process.argv.indexOf('--watch') == -1) {
console.log(stats.compilation.errors);
process.exit(1); // webpack doesn't exit with status code != 0 if there are errors
}
});
}]
};
module.exports = config;