带进口电子(聚合物)

时间:2017-10-28 08:47:16

标签: polymer electron

我试图用聚合物创建一个电子应用程序。我尝试使用

导入自定义元素
<link rel="import" href="src/lux-app.html">

但它没有工作。控制台说:

GET file:///D:/src/lux-app.html net::ERR_FILE_NOT_FOUND

它没有使用正确的路径。我研究并发现只有在服务器(例如localhost)上才能使用导入。有没有办法在电子或类似的东西中运行localhost?

谢谢

修改 这是文件结构

lux-app
   |── bower_components
   |── images
   |── lib
       └── artnet.js
   |── lux-app.html
   |── .gitignore
   |── bower.json
   |── ...
node_modules
   └── node stuff
main.js
index.html
polymer.json
package.json
README.json
renderer.js

1 个答案:

答案 0 :(得分:1)

导入工作没有“localhost”,正如我在"Electron Api demos"中看到的那样。在 index.html 文件中,有一些导入如下:

    const CopyWebpackPlugin = require('copy-webpack-plugin').CopyWebpackPlugin;
    ....
    const clientBundleConfig = merge(sharedConfig, {
    entry: { 'main-client': './ClientApp/boot.browser.ts' },
    output: { path: path.join(__dirname, clientBundleOutputDir) },
    plugins: [
        new webpack.CopyWebpackPlugin(
            { from: './ClientApp/assets', to: './wwwroot/dist/assets', toType : 'dir' }
        ),
        new webpack.DllReferencePlugin({
            context: __dirname,
            manifest: require('./wwwroot/dist/vendor-manifest.json')
        })
    ].concat(isDevBuild ? [
        // Plugins that apply in development builds only
        new webpack.SourceMapDevToolPlugin({                
            filename: '[file].map', // Remove this line if you prefer inline source maps
            moduleFilenameTemplate: path.relative(clientBundleOutputDir, '[resourcePath]') // Point sourcemap entries to the original file locations on disk
        })
    ] : [
        // Plugins that apply in production builds only
        new webpack.optimize.UglifyJsPlugin(),
        new AngularCompilerPlugin({                
            tsConfigPath: './tsconfig.json',
            entryModule: path.join(__dirname, 'ClientApp/app/app.browser.module#AppModule'),
            exclude: ['./**/*.server.ts']
        })
    ])
});

所以我认为您的问题是主渲染器(main.js)中的路径变量无法正常工作,或者如果您尚未声明该变量,则需要使用{ {1}}并使用电子Api演示中 main.js 文件中的路径。

(我不是电子专家,但我想我可以让你找到解决电子api回购文件内部解决方案的方法)

相关问题