这个包electron-compile看起来非常酷,但我无法让它工作。我收到此错误:
Uncaught Exception:
SyntaxError: Unexpected token e
at Object.parse (native)
at createCompilerHostFromConfigFileSync (/Users/josh/Projects/jadeElectronTest/node_modules/electron-compile/lib/config-parser.js:406:19)
at createCompilerHostFromProjectRootSync (/Users/josh/Projects/jadeElectronTest/node_modules/electron-compile/lib/config-parser.js:426:12)
at Object.init (/Users/josh/Projects/jadeElectronTest/node_modules/electron-compile/lib/config-parser.js:132:20)
at Object.<anonymous> (/Users/josh/Projects/jadeElectronTest/app/es6-init.js:7:29)
at Module._compile (module.js:425:26)
at Object.Module._extensions..js (module.js:432:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:313:12)
at loadApplicationPackage (/Users/josh/Projects/jadeElectronTest/node_modules/electron-prebuilt/dist/Electron.app/Contents/Resources/default_app/main.js:257:23)
我已根据说明将electron-compile
和electron-compilers
添加为devDependency。
以下是我的文件:
// es6-init.js
var path = require('path');
var appRoot = path.join(__dirname, '..');
require('electron-compile').init(appRoot, './main');
// index.html
<html>
<head>
<link rel="stylesheet" href="./styles/main.less">
</head>
<body>
<h1>Hello World!</h1>
We are using Electron
<script> document.write(process.versions['electron']) </script> on
<script> document.write(process.platform) </script>
<script type="text/javascript">
var fs = require('fs-extra');
var file = fs.readFileSync('package.json');
document.write(file);
</script>
</body>
</html>
任何帮助表示赞赏! 谢谢!
// .compilerc
{
"env": {
"development": {
"application/javascript": {
"presets": ["es2015"],
"sourceMaps": "inline"
},
"text/less": {
"dumpLineNumbers": "comments"
}
},
"production": {
"application/javascript": {
"presets": ["es2015"],
"sourceMaps": "none"
}
}
}
}