forked from Doist/reactist
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.babel.js
75 lines (71 loc) · 1.93 KB
/
webpack.config.babel.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
74
75
import path from 'path'
import webpack from 'webpack'
import { getComponentsMap } from './scripts/buildHelpers'
const BASE_CONFIG = {
entry: './src/index.js',
devtool: 'source-map',
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'reactist.js',
library: 'reactist',
libraryTarget: 'umd',
umdNamedDefine: true,
sourceMapFilename: 'reactist.map'
},
resolve: {
modules: [
path.resolve(__dirname, 'node_modules'),
'node_modules',
'src'
],
extensions: ['.webpack.js', '.js', '.jsx']
},
module: {
loaders: [
{
test: /\.jsx?$/,
exclude: /node_modules/,
loader: 'babel-loader'
},
{ test: /\.less$/, loader: 'style-loader!css-loader!less-loader' },
{ test: /\.css$/, loader: 'style-loader!css-loader' },
{ test: /\.svg$/, loader: 'svg-url-loader' }
]
},
externals: {
react: {
root: 'React',
commonjs2: 'react',
commonjs: 'react',
amd: 'react'
},
'react-dom': {
root: 'ReactDOM',
commonjs2: 'react-dom',
commonjs: 'react-dom',
amd: 'react-dom'
}
},
plugins: [
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify('production')
}
})
]
}
const createConfig = overriddenAttributes => ({
...BASE_CONFIG,
...overriddenAttributes
})
const mainConfig = createConfig()
const modulesConfig = createConfig({
entry: getComponentsMap(path.resolve(__dirname, './src/components')),
output: {
...BASE_CONFIG.output,
path: path.resolve(__dirname, 'lib'),
filename: '[name].js',
sourceMapFilename: '[name].map'
}
})
module.exports = [mainConfig, modulesConfig]