-
Notifications
You must be signed in to change notification settings - Fork 2
/
getWebpackConfig.js
48 lines (44 loc) · 1.13 KB
/
getWebpackConfig.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
'use strict'
// Generates standard webpack.config.js export for JSX packages and widgets
const path = require('path')
const PeerDepsExternals = require('peer-deps-externals-webpack-plugin')
const { jsxPackages } = require('./jsx-packages')
function getWebpackConfig(dirname) {
const jsxPackagePaths = jsxPackages.map(name =>
path.resolve(dirname, '..', name)
)
return {
entry: './index.js',
mode: 'development',
output: {
path: path.resolve(dirname, 'build'),
filename: 'index.js',
libraryTarget: 'commonjs2',
},
module: {
rules: [
{
test: /\.js$/,
include: jsxPackagePaths,
exclude: /([\\/](node_modules|build)[\\/]|webpack)/,
use: {
loader: 'babel-loader',
options: {
rootMode: 'upward',
},
},
},
{
test: /\.md$/,
loader: 'raw-loader',
},
{
test: /\.(png|woff|woff2|eot|ttf|otf|svg|mock)$/,
loader: 'file-loader',
},
],
},
plugins: [new PeerDepsExternals()],
}
}
module.exports = getWebpackConfig