-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathwebpack.shared.js
More file actions
59 lines (57 loc) · 1.73 KB
/
webpack.shared.js
File metadata and controls
59 lines (57 loc) · 1.73 KB
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
const path = require('path');
const Template = require('webpack/lib/Template');
const shared = ({ publicPath, dir, target = 'web' }) => ({
mode: 'development',
target,
output: {
path: path.resolve(dir, 'dist'),
publicPath,
devtoolNamespace: Template.toIdentifier(publicPath + target),
jsonpFunction: Template.toIdentifier(publicPath + target + '-jsonp'),
hotUpdateFunction: Template.toIdentifier(publicPath + target + '-webpackHotUpdate'),
chunkCallbackName: Template.toIdentifier(publicPath + target + '-webpackChunk'),
filename: '[name].js',
libraryTarget: 'amd',
},
resolve: {
extensions: ['.js', '.jsx']
},
module: {
rules: [
{
enforce: 'pre',
test: /\.jsx?$/,
include: [path.resolve(dir, 'src')],
loader: 'eslint-loader'
},
{
test: /\.jsx?$/,
include: [path.resolve(dir, 'src')],
loader: 'babel-loader'
},
{
test: /\.hbs$/,
include: [path.resolve(dir, 'src')],
use: [
{
loader: 'handlebars-loader',
options: {
ignoreHelpers: true,
ignorePartials: true,
inlineRequires: true,
runtime: 'handlebars'
}
}
]
}
]
}
});
const externals = (...list) => list.reduce((map, entry) => {
map[entry] = { amd: entry };
return map;
}, {});
module.exports = {
shared,
externals
}