Skip to content

Commit de3c862

Browse files
committed
Update configuration to enable enhanced playback
1 parent ecb2457 commit de3c862

4 files changed

Lines changed: 49 additions & 6 deletions

File tree

config/dev8-plugin.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
const HtmlWebpackPlugin = require('html-webpack-plugin')
2+
3+
const createDev8Plugin = ({src}) => ({
4+
apply: (compiler) => {
5+
if (!src) {
6+
throw new Error('createDev8Plugin called without src')
7+
}
8+
compiler.hooks.compilation.tap('Dev8Plugin', (compilation) => {
9+
HtmlWebpackPlugin.getCompilationHooks(compilation).beforeEmit.tap(
10+
'Dev8Plugin',
11+
(data) => {
12+
data.html = data.html.replace(
13+
'</head>',
14+
` <script crossorigin="anonymous" src="${src}"></script>\n</head>`
15+
)
16+
return data
17+
}
18+
)
19+
})
20+
},
21+
})
22+
23+
module.exports = createDev8Plugin

config/webpack.config.js

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ const HtmlWebpackPlugin = require('html-webpack-plugin')
33
const CopyWebpackPlugin = require('copy-webpack-plugin')
44

55
const createVirtualEntryPlugin = require('./entry-plugin')
6+
const createDev8Plugin = require('./dev8-plugin')
67

78
const rootPath = process.cwd()
89
const distPath = path.join(rootPath, 'dist')
@@ -87,4 +88,23 @@ const config = {
8788
},
8889
}
8990

90-
module.exports = config
91+
module.exports = (_, argv) => {
92+
if (argv.mode === 'development') {
93+
return {
94+
...config,
95+
plugins: [
96+
...config.plugins,
97+
createDev8Plugin({src: './external/dev8/dev8.js'}),
98+
new CopyWebpackPlugin({
99+
patterns: [{
100+
from: path.join(rootPath, 'node_modules/@8thwall/ecs/dev8'),
101+
to: path.join(distPath, 'external/dev8'),
102+
noErrorOnMissing: true,
103+
}],
104+
}),
105+
],
106+
}
107+
}
108+
109+
return config
110+
}

package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,6 @@
2525
"webpack-virtual-modules": "^0.6.2"
2626
},
2727
"dependencies": {
28-
"@8thwall/ecs": "^3.0.1"
28+
"@8thwall/ecs": "^3.1.0"
2929
}
3030
}

0 commit comments

Comments
 (0)