Skip to content
Permalink
Browse files

feat: support native modules in webpack template

  • Loading branch information
MarshallOfSound committed May 24, 2019
1 parent 6bd2bfc commit ed5fd37101b5c89a8a3e008736809fc8a93d2fa6
@@ -207,7 +207,11 @@ Your packaged app may be larger than expected if you dont ignore everything othe
}

getDefines = (inRendererDir = true) => {
const defines: { [key: string]: string; } = {};
const defines: { [key: string]: string; } = {
ASSET_RELOCATOR_BASE_DIR: this.isProd
? 'process.resourcesPath + "/" + (__filename.indexOf(".asar") === -1 ? "app" : "app.asar") + "/.webpack/renderer/native_modules"'
: JSON.stringify(path.resolve(this.baseDir, 'renderer', 'native_modules')),
};
if (!this.config.renderer.entryPoints || !Array.isArray(this.config.renderer.entryPoints)) {
throw new Error('Required config option "renderer.entryPoints" has not been defined');
}
@@ -400,6 +404,7 @@ Your packaged app may be larger than expected if you dont ignore everything othe
publicPath: '/',
hot: true,
historyApiFallback: true,
writeToDisk: true,
} as any);
const app = express();
app.use(server);
@@ -8,7 +8,10 @@ const currentVersion = require('../package').version;

class WebpackTemplate implements ForgeTemplate {
public devDependencies = [
`@electron-forge/plugin-webpack@${currentVersion}`
`@electron-forge/plugin-webpack@${currentVersion}`,
// TODO: Use the @zeit publish once https://github.com/zeit/webpack-asset-relocator-loader/pull/41 has been merged
'@marshallofsound/webpack-asset-relocator-loader@^0.5.0',
'node-loader^0.6.0',
];

public initializeTemplate = async (directory: string) => {
@@ -1,3 +1,11 @@
module.exports = {
/**
* This is the main entry point for your application, it's the first file
* that runs in the main process.
*/
entry: './src/main.js',
// Put your normal webpack config below here
module: {
rules: require('./webpack.rules'),
},
};
@@ -1,4 +1,19 @@
module.exports = [
// Add support for native node modules
{
test: /\.node$/,
use: 'node-loader',
},
{
test: /\.(m?js|node)$/,
parser: { amd: false },
use: {
loader: '@zeit/webpack-asset-relocator-loader',
options: {
outputAssetBase: 'native_modules',
},
},
},
// Put your webpack loader rules in this array. This is where you would put
// your ts-loader configuration for instance:
/**

0 comments on commit ed5fd37

Please sign in to comment.
You can’t perform that action at this time.