-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwebpack.config.js
148 lines (133 loc) · 3.27 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
142
143
144
145
146
147
148
const path = require('path');
const WebpackShellPlugin = require('webpack-shell-plugin');
const config = {
// Stand-alone script files
standAlone: {
entry: './src/stand-alone/togglific.js',
output: {
path: './src/bundles/stand-alone',
filename: 'bundle.js'
}
},
// Bookmarklet script files
bookmarklet: {
entry: './src/bookmarklet/togglific.js',
output: {
path: './src/bundles/bookmarklet',
filename: 'bundle.js'
}
},
// Bookmarklet demo file -- replaces " with " for href attribute inclusion
bookmarkletDemo: {
entry: './src/bookmarklet/togglific.js',
output: {
path: './src/bundles/bookmarklet',
filename: 'bundle-demo.js'
},
plugins: [
new WebpackShellPlugin({
onBuildExit: ['npm run bookmarklet-demo']
})
]
},
// Browser extension files
browserExtension: {
entry: './src/browser-extension/togglific.js',
output: {
path: './src/bundles/browser-extension',
filename: 'bundle.js'
}
},
// `npm` package file
npmPackage: {
entry: './src/stand-alone/togglific.js',
output: {
path: './dist/npm-package',
filename: 'index.js'
}
},
// Brochure
brochure: {
entry: [
'@babel/polyfill',
'./brochure/javascript/polyfills/matchMedia.js',
'./brochure/javascript/polyfills/classList.js',
'./brochure/javascript/vendor/head.js',
'./brochure/javascript/polyfills/raf.js',
'./brochure/javascript/brochure.js'
],
output: {
path: './brochure/javascript',
filename: 'brochure.min.js'
}
},
// Webpack modules config
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
loader: 'babel-loader'
}
]
}
};
module.exports = [
// Stand-alone script
{
entry: config.standAlone.entry,
output: {
path: path.resolve(__dirname, config.standAlone.output.path),
filename: config.standAlone.output.filename,
library: 'Togglific'
},
module: config.module
},
// Bookmarklet
{
entry: config.bookmarklet.entry,
output: {
path: path.resolve(__dirname, config.bookmarklet.output.path),
filename: config.bookmarklet.output.filename
},
module: config.module
},
// Bookmarklet demo
{
entry: config.bookmarkletDemo.entry,
output: {
path: path.resolve(__dirname, config.bookmarkletDemo.output.path),
filename: config.bookmarkletDemo.output.filename
},
module: config.module,
plugins: config.bookmarkletDemo.plugins
},
// Browser extension
{
entry: config.browserExtension.entry,
output: {
path: path.resolve(__dirname, config.browserExtension.output.path),
filename: config.browserExtension.output.filename
},
module: config.module
},
// `npm` package`
{
entry: config.npmPackage.entry,
output: {
path: path.resolve(__dirname, config.npmPackage.output.path),
filename: config.npmPackage.output.filename,
libraryTarget: 'commonjs2'
},
module: config.module
},
// Brochure
{
entry: config.brochure.entry,
output: {
path: path.resolve(__dirname, config.brochure.output.path),
filename: config.brochure.output.filename
},
module: config.module
}
];