【问题标题】:Autodesk Viewer Markup extension - can't compile from sourcesAutodesk 查看器标记扩展 - 无法从源代码编译
【发布时间】:2017-04-27 11:35:26
【问题描述】:

我正在尝试实现类似的查看器注释,如官方演示: lvm-react

我阅读了官方博客文章并使用来自 Autodesk Extensions github 的文件: http://adndevblog.typepad.com/cloud_and_mobile/2016/04/markup3d-sample-for-view-data-api.html

但我无法从源代码编译扩展(创建 bundle.js)。尝试了 npm install ,但是有很多错误,例如:

ERROR in ./src/Viewing.Extension.VisualReport/PieChart/PieChart.js
Module not found: Error: Cannot resolve module 'EventsEmitter' in MY_FILES

ERROR in ./src/Viewing.Extension.StateManager/Viewing.Extension.StateManager.scss
Module parse failed: /MY_PATH/library-javascript-viewer-extensions-master/src/Viewing.Extension.StateManager/Viewing.Extension.StateManager.scss Unexpected token (2:0)
You may need an appropriate loader to handle this file type.

我也用npm安装了webpack,但是没有结果,还是有很多错误。

【问题讨论】:

    标签: autodesk autodesk-forge autodesk-viewer


    【解决方案1】:

    webpack 构建生产配置中缺少一些加载器。它现在已修复,您应该能够构建所有扩展。请使用 repo 中的最新版本。

    在测试你的扩展时,我建议你使用 npm run build-dev 命令,这样生成的扩展文件不会被缩小并且启用了源映射,所以您可以在浏览器控制台中轻松调试它们。在为生产构建时,您可以使用 npm run build-prod

    您还可以从 webpack 配置中删除各种条目以仅构建您感兴趣的扩展,例如:

    module.exports = {
    
        devtool: 'eval-source-map',
    
        entry: {
    
          'Viewing.Extension.Markup3D':
            './src/Viewing.Extension.Markup3D/Viewing.Extension.Markup3D.js',
        },
    
        // ... rest of the config ...
    

    您可能还想更改输出路径,在我的配置中,输出位于扩展目录之外,直接在使用它们的项目中:

    output: {
        path: path.join(__dirname, '../../App/dynamic/extensions'),
        filename: "[name]/[name].js",
        libraryTarget: "umd",
        library: "[name]",
        watch: true
      },
    

    除了在项目中包含扩展文件之外,您还应该确保在任何扩展脚本之前包含 babel polyfill(来自 node_modules/babel-polyfill/dist/polyfill.min.js)。

    希望对您有所帮助,如果您在使用这些扩展程序时遇到任何问题,请告诉我。

    【讨论】:

      猜你喜欢
      • 2010-10-02
      • 2021-09-18
      • 2016-08-27
      • 2021-05-30
      • 2022-01-13
      • 1970-01-01
      • 2015-04-19
      • 2021-03-19
      • 2021-01-10
      相关资源
      最近更新 更多