-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathwebpack.config.js
59 lines (52 loc) · 1.49 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
const path = require('path')
const srcPath = path.join(process.cwd(), 'src') + path.sep
const outputPath = path.join(__dirname, 'build') + path.sep
const widgetWebpack = require('materia-widget-development-kit/webpack-widget')
const rules = widgetWebpack.getDefaultRules()
const entries = widgetWebpack.getDefaultEntries()
const copy = widgetWebpack.getDefaultCopyList()
// no creator
delete entries['creator.css']
delete entries['creator.js']
// change player.js from '.coffee' to '.js'
entries['player.js'] = [srcPath+'player.js']
// copy libs from node_modules
const customCopy = copy.concat([
{
from: path.join(process.cwd(), 'node_modules', 'jsxgraph', 'distrib', 'jsxgraphcore.js'),
to: path.join(outputPath, 'vendor', 'jsxgraph')
},
{
from: path.join(process.cwd(), 'node_modules', 'jquery', 'dist', 'jquery.min.js'),
to: path.join(outputPath, 'vendor', 'jquery')
},
{
from: path.join(process.cwd(), 'node_modules', 'mathquill', 'build'),
to: path.join(outputPath, 'vendor', 'mathquill')
}
])
// babel webpack rule
const babelJS = {
test: /\.js$/i,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
options: {
presets: ['env']
}
}
};
let customRules = [
rules.copyImages,
rules.loadHTMLAndReplaceMateriaScripts,
rules.loadAndPrefixCSS,
rules.loadAndPrefixSASS,
babelJS, // <--- Babel loader
]
// options for the build
let options = {
entries: entries,
copyList: customCopy,
moduleRules: customRules
}
module.exports = widgetWebpack.getLegacyWidgetBuildConfig(options)