-
Notifications
You must be signed in to change notification settings - Fork 5
/
webpack.config.js
98 lines (88 loc) · 2.47 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
const fs = require('fs')
const path = require('path')
const srcPath = path.join(process.cwd(), 'src') + path.sep
const outputPath = path.join(process.cwd(), 'build') + path.sep
const widgetWebpack = require('materia-widget-development-kit/webpack-widget')
// grab original copyList - we're going to append to it and overwrite the default copyList
let copyList = widgetWebpack.getDefaultCopyList()
const rules = widgetWebpack.getDefaultRules()
// Append the new items we want copied
copyList.push(
{
from: `${srcPath}_exports/`,
to: `${outputPath}_exports`,
},
{
from: `${__dirname}/node_modules/micromarkdown/dist/micromarkdown.min.js`,
to: `${outputPath}assets/micromarkdown.min.js`,
},
{
from: `${srcPath}/_guides/assets`,
to: `${outputPath}/guides/assets`,
toType: 'dir'
}
)
// completely replace the default entries with ours
const entries = {
"player": [
srcPath+"player.html",
srcPath+"src-assets/player-assets/player.scss",
srcPath+"src-assets/player-assets/app.coffee",
srcPath+"src-assets/player-assets/player.coffee",
srcPath+"src-assets/services/inventoryService.coffee",
srcPath+"src-assets/services/legacyQsetSrv.coffee"
],
"creator": [
srcPath+"creator.html",
srcPath+"src-assets/creator-assets/creator.scss",
srcPath+"src-assets/creator-assets/app.coffee",
srcPath+"src-assets/creator-assets/services.coffee",
srcPath+"src-assets/creator-assets/controllers.coffee",
srcPath+"src-assets/creator-assets/directives.coffee",
srcPath+"src-assets/services/legacyQsetSrv.coffee"
],
"scoreScreen": [
srcPath+"scoreScreen.html",
srcPath+"src-assets/score-assets/score.scss",
srcPath+"src-assets/score-assets/app.coffee",
srcPath+"src-assets/score-assets/score.coffee",
srcPath+"src-assets/services/inventoryService.coffee",
srcPath+"src-assets/services/legacyQsetSrv.coffee"
]
}
const babelLoaderWithPolyfillRule = {
test: /\.js$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
options: {
presets: [
'@babel/preset-env',
{
targets: {
browsers: [
">0.25%",
"not ie 10",
"not op_mini all"
]
},
}
]
}
}
}
const moduleRules = [
rules.loaderCompileCoffee,
babelLoaderWithPolyfillRule,
rules.copyImages,
rules.loadHTMLAndReplaceMateriaScripts,
rules.loadAndPrefixSASS
]
let options = {
entries,
copyList,
moduleRules
}
let build = widgetWebpack.getLegacyWidgetBuildConfig(options)
// load the reusable legacy webpack config from materia-widget-dev
module.exports = build