@cpp.js/plugin-webpack 2.0.0-beta.12 → 2.0.0-beta.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +47 -0
- package/package.json +2 -2
package/index.js
CHANGED
|
@@ -68,4 +68,51 @@ export default class CppjsWebpackPlugin {
|
|
|
68
68
|
getFilteredBuildTargets
|
|
69
69
|
};
|
|
70
70
|
}
|
|
71
|
+
|
|
72
|
+
getRule() {
|
|
73
|
+
return {
|
|
74
|
+
test: new RegExp(`\\.(${state.config.ext.header.join('|')})$`),
|
|
75
|
+
loader: '@cpp.js/plugin-webpack-loader',
|
|
76
|
+
options: { ...this.getLoaderOptions() },
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
setDevServerMiddleware(middlewares, devServer) {
|
|
81
|
+
if (!devServer) {
|
|
82
|
+
throw new Error('devServer is not defined');
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
middlewares.unshift({
|
|
86
|
+
name: '/cpp.js',
|
|
87
|
+
path: '/cpp.js',
|
|
88
|
+
middleware: (req, res) => {
|
|
89
|
+
const filePath = `${state.config.paths.build}/${buildTargetDebug.jsName}`;
|
|
90
|
+
res.setHeader('Content-Type', 'application/javascript');
|
|
91
|
+
fs.createReadStream(filePath).pipe(res);
|
|
92
|
+
},
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
middlewares.unshift({
|
|
96
|
+
name: '/cpp.wasm',
|
|
97
|
+
path: '/cpp.wasm',
|
|
98
|
+
middleware: (req, res) => {
|
|
99
|
+
const filePath = `${state.config.paths.build}/${buildTargetDebug.wasmName}`;
|
|
100
|
+
res.setHeader('Content-Type', 'application/wasm');
|
|
101
|
+
fs.createReadStream(filePath).pipe(res);
|
|
102
|
+
},
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
return middlewares;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
getDevServerConfig() {
|
|
109
|
+
return {
|
|
110
|
+
watchFiles: state.config.paths.native,
|
|
111
|
+
hot: true,
|
|
112
|
+
liveReload: true,
|
|
113
|
+
setupMiddlewares: (middlewares, devServer) => {
|
|
114
|
+
return this.setDevServerMiddleware(middlewares, devServer);
|
|
115
|
+
},
|
|
116
|
+
};
|
|
117
|
+
}
|
|
71
118
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cpp.js/plugin-webpack",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.13",
|
|
4
4
|
"description": "Cpp.js Webpack plugin: A tool for seamless C++ integration with the Webpack bundler.",
|
|
5
5
|
"homepage": "https://github.com/bugra9/cpp.js/tree/main/packages/cppjs-plugin-rollup#readme",
|
|
6
6
|
"repository": "https://github.com/bugra9/cpp.js.git",
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"type": "module",
|
|
9
9
|
"main": "index.js",
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"cpp.js": "^2.0.0-beta.
|
|
11
|
+
"cpp.js": "^2.0.0-beta.13"
|
|
12
12
|
},
|
|
13
13
|
"keywords": [
|
|
14
14
|
"cpp.js-plugin",
|