-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.babel.js
158 lines (140 loc) · 4.32 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
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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
/* eslint-disable max-len */
const path = require('path');
const entry = {
class: path.resolve(__dirname, 'src/class.es'),
dom: path.resolve(__dirname, 'dom.es'),
html: path.resolve(__dirname, 'src/html.es'),
//'html/input': path.resolve(__dirname, 'src/html/input.es'), // Don't feel like this belongs in dist either.
ncss: path.resolve(__dirname, 'ncss.es'),
obj: path.resolve(__dirname, 'src/obj.es'),
//svg: path.resolve(__dirname, 'src/svg.es'), // Not needed in dist
util: path.resolve(__dirname, 'src/util.es') // Might not belong in dist, but could be useful.
};
const devtool = 'source-map'; // sourceMaps might be useful in browser
const mode = 'production';
const stats = {
colors: true,
hash: false,
maxModules: 0,
modules: false,
moduleTrace: false,
timings: false,
version: false
};
const DIST_CONFIG = {
entry,
devtool,
mode,
module: {
rules: [{
test: /\.(es6?|js)$/,
use: [{
loader: 'babel-loader',
options: {
babelrc: false, // The .babelrc file should only be used to transpile *.babel.js files.
comments: false,
compact: true,
minified: true,
plugins: [
'array-includes',
'optimize-starts-with',
'transform-object-assign',
'transform-object-rest-spread'
],
presets: ['env']
} // options
}] // use
}] // rules
}, // module
output: {
path: path.join(__dirname, './dist/'), // Must be absolute in webpack3
filename: '[name].js',
libraryTarget: 'commonjs'
},
stats
}; // DIST_CONFIG
const LIB_CONFIG = {
entry,
devtool,
mode,
module: {
rules: [{
test: /\.(es6?|js)$/,
use: [{
loader: 'babel-loader',
options: {
babelrc: false, // The .babelrc file should only be used to transpile *.babel.js files.
comments: false,
compact: true,
minified: true,
plugins: [
//'array-includes', // TODO does modern browsers support this?
//'optimize-starts-with', // TODO does modern browsers support this?
// Does browsers implement support for module loading?
// https://www.contentful.com/blog/2017/04/04/es6-modules-support-lands-in-browsers-is-it-time-to-rethink-bundling/
// If not do this:
//'transform-es2015-modules-commonjs',
//'transform-object-assign', // TODO does modern browsers support this?
'transform-object-rest-spread' // or webpack will fail
],
presets: [] // No preset since we want ECMAScript 2015
} // options
}] // use
}] // rules
}, // module
output: {
path: path.join(__dirname, './lib/'), // Must be absolute in webpack3
filename: '[name].js'//,
//libraryTarget: 'commonjs'
},
stats
}; // LIB_CONFIG
const ENONIC_CONFIG = {
entry: {
class: path.resolve(__dirname, 'src/class.es'),
css: path.resolve(__dirname, 'src/css.es'),
html: path.resolve(__dirname, 'src/html.es'),
obj: path.resolve(__dirname, 'src/obj.es'),
//svg: path.resolve(__dirname, 'src/svg.es'),
util: path.resolve(__dirname, 'src/util.es'),
dom: path.resolve(__dirname, 'dom.es'),
index: path.resolve(__dirname, 'html.es'),
//input: path.resolve(__dirname, 'input.js'),
ncss: path.resolve(__dirname, 'ncss.es')
},
devtool: false, // Don't waste time generating sourceMaps for Enonic server-side
mode,
module: {
rules: [{
test: /\.(es6?|js)$/,
use: [{
loader: 'babel-loader',
options: {
babelrc: false, // The .babelrc file should only be used to transpile *.babel.js files.
comments: false,
compact: false,
minified: false,
plugins: [
'array-includes',
'optimize-starts-with',
'transform-object-assign',
'transform-object-rest-spread'
],
presets: ['env']
} // options
}] // use
}] // rules
}, // module
output: {
path: path.join(__dirname, './build/resources/main/lib/render-js/'), // Must be absolute in webpack3
filename: '[name].js',
libraryTarget: 'commonjs'
},
stats
}; // ENONIC_CONFIG
const WEBPACK_CONFIG = [
DIST_CONFIG,
LIB_CONFIG,
ENONIC_CONFIG
];
export { WEBPACK_CONFIG as default };