-
Notifications
You must be signed in to change notification settings - Fork 10
/
webpack.config.js
141 lines (139 loc) · 3.65 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
const webpack = require('webpack');
const path = require('path');
const banner = require('./tasks/banner');
const config = require('./project.config');
const TARGET = config.target.env;
const MAIN_ENTRY = path.join(__dirname, config.dir.built, config.main.basename + '.js');
const OUTPUT_PATH = path.join(__dirname, config.dir.pkg);
const OUTPUT_FILE_NAME = config.main.basename + '.js';
const OUTPUT_LIB_TARGET = ('commonjs' === config.target.module) ? 'commonjs2' : config.target.module;
module.exports = {
target: TARGET,
entry: [
MAIN_ENTRY,
],
output: {
path: OUTPUT_PATH,
filename: OUTPUT_FILE_NAME,
libraryTarget: OUTPUT_LIB_TARGET,
},
node: {
__dirname: false,
__filename: false,
},
devtool: 'inline-source-map',
module: {
rules: [
{
test: /\.js$/,
use: ["source-map-loader"],
enforce: "pre",
},
],
},
// externals を指定しない場合、3rd Library の使用するものを concat 可能
externals: {
'express': {
commonjs: 'express',
commonjs2: 'express',
},
'cli-spinner': {
commonjs: 'cli-spinner',
commonjs2: 'cli-spinner',
},
'deep-extend': {
commonjs: 'deep-extend',
commonjs2: 'deep-extend',
},
'opn': {
commonjs: 'opn',
commonjs2: 'opn',
},
'cdp-doc': {
commonjs: 'cdp-doc',
commonjs2: 'cdp-doc',
},
'cdp-lib': {
commonjs: 'cdp-lib',
commonjs2: 'cdp-lib',
},
'commander': {
commonjs: 'commander',
commonjs2: 'commander',
},
'inquirer': {
commonjs: 'inquirer',
commonjs2: 'inquirer',
},
// 以下は cdp-lib でも使用するもの
'fs-extra': {
commonjs: 'fs-extra',
commonjs2: 'fs-extra',
},
'jquery': {
root: 'jQuery',
commonjs: 'jquery',
commonjs2: 'jquery',
amd: 'jquery'
},
'hogan.js': {
root: 'Hogan',
commonjs: 'hogan.js',
commonjs2: 'hogan.js',
amd: 'hogan.js'
},
'jsdom': {
commonjs: 'jsdom',
commonjs2: 'jsdom',
},
'xmldom': {
commonjs: 'xmldom',
commonjs2: 'xmldom',
},
'glob': {
commonjs: 'glob',
commonjs2: 'glob',
},
'lodash': {
root: '_',
commonjs: 'lodash',
commonjs2: 'lodash',
},
'uuid': {
commonjs: 'uuid',
commonjs2: 'uuid',
},
'semver-regex': {
commonjs: 'semver-regex',
commonjs2: 'semver-regex',
},
'underscore.string': {
root: '_',
commonjs: 'underscore.string',
commonjs2: 'underscore.string',
},
'which': {
commonjs: 'which',
commonjs2: 'which',
},
'chalk': {
commonjs: 'chalk',
commonjs2: 'chalk',
}
},
//resolve: {
// alias: {
// 'cdp-lib': '../submodules/cdp-lib/dist/cdp-lib.js',
// },
//},
plugins: [
new webpack.optimize.LimitChunkCountPlugin({
maxChunks: 1,
}),
new webpack.BannerPlugin({
banner: banner('.js'),
raw: true,
ntryOnly: true,
}),
],
};