-
Notifications
You must be signed in to change notification settings - Fork 7
/
webpack.config.js
56 lines (47 loc) · 1.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
// grab webpack config from MWDK
const widgetWebpack = require('materia-widget-development-kit/webpack-widget')
// replace default entries
const entries = {
'js/player.js': ['./src/js/player.js'],
'player.css': [
'./src/player.html',
'./src/player.scss',
'./src/react-joyride-compiled.scss',
'./src/custom-joyride.scss'
]
}
// get default ruleset from widget config - need to create new ruleset by bundling default + custom
const rules = widgetWebpack.getDefaultRules()
// create new JS rules for transpiling babel (vs. raw-loader, the default)
const customDoNothingToJs = {
test: /\.js$/,
use: {
loader: 'babel-loader',
options: {
presets: ['babel-preset-env']
}
},
exclude: /(node_modules|bower_components)/,
}
// create new ruleset
const customRules = [
customDoNothingToJs,
rules.loadAndPrefixCSS,
rules.loadAndPrefixSASS,
rules.loadHTMLAndReplaceMateriaScripts,
rules.copyImages,
]
// create options object to pass to build config
const options = {
moduleRules: customRules,
entries: entries
}
const config = widgetWebpack.getLegacyWidgetBuildConfig(options)
// prevent webpack from including these, we'll load from a cdn
config.externals = {
react: 'React',
'react-dom': 'ReactDOM',
redux: 'Redux',
aframe: 'AFRAME'
}
module.exports = config