尝试构建 ember js 项目时出错


每当我使用 outputPath=dist 和环境

= 生产构建我的 ember 项目时,它都可以正常构建,但是当我使用 outputPath=dist-something 和环境=hosted-something 构建时,我会收到以下错误:

Build failed.
Invalid mapping: {"generated":{"line":74176,"column":-50},**"source":"bower_components/moment/min/moment.min.js"**,"original
":{"line":1,"column":0},"name":null}
Error: Invalid mapping: {"generated":{"line":74176,"column":-50},"source":"bower_components/moment/min/moment.min.js","o
riginal":{"line":1,"column":0},"name":null}
    at SourceMapGenerator_validateMapping [as _validateMapping] (C:wampwwwPublicMDEmberMDTatrunkTextAdminLatestEm
bernode_modulesember-cli-uglifynode_modulesbroccoli-uglify-sourcemapnode_modulesuglify-jsnode_modulessource-map
libsource-mapsource-map-generator.js:272:15)
    at SourceMapGenerator_addMapping [as addMapping] (C:wampwwwPublicMDEmberMDTatrunkTextAdminLatestEmbernode_mo
dulesember-cli-uglifynode_modulesbroccoli-uglify-sourcemapnode_modulesuglify-jsnode_modulessource-maplibsource-
mapsource-map-generator.js:102:12)
    at C:wampwwwPublicMDEmberMDTatrunkTextAdminLatestEmbernode_modulesember-cli-uglifynode_modulesbroccoli-ug
lify-sourcemapnode_modulesuglify-jsnode_modulessource-maplibsource-mapsource-map-generator.js:74:19
    at Array.forEach (native)
    at SourceMapConsumer_eachMapping [as eachMapping] (C:wampwwwPublicMDEmberMDTatrunkTextAdminLatestEmbernode_m
odulesember-cli-uglifynode_modulesbroccoli-uglify-sourcemapnode_modulesuglify-jsnode_modulessource-maplibsource
-mapsource-map-consumer.js:473:10)
    at Function.SourceMapGenerator_fromSourceMap [as fromSourceMap] (C:wampwwwPublicMDEmberMDTatrunkTextAdminLate
stEmbernode_modulesember-cli-uglifynode_modulesbroccoli-uglify-sourcemapnode_modulesuglify-jsnode_modulessource-
maplibsource-mapsource-map-generator.js:50:26)
    at Context.SourceMap (C:wampwwwPublicMDEmberMDTatrunkTextAdminLatestEmbernode_modulesember-cli-uglifynode_
modulesbroccoli-uglify-sourcemapnode_modulesuglify-jslibsourcemap.js:59:52)
    at Object.exports.minify (C:wampwwwPublicMDEmberMDTatrunkTextAdminLatestEmbernode_modulesember-cli-uglifyn
ode_modulesbroccoli-uglify-sourcemapnode_modulesuglify-jstoolsnode.js:112:38)
    at UglifyWriter.processFile (C:wampwwwPublicMDEmberMDTatrunkTextAdminLatestEmbernode_modulesember-cli-uglif
ynode_modulesbroccoli-uglify-sourcemapindex.js:98:25)
    at C:wampwwwPublicMDEmberMDTatrunkTextAdminLatestEmbernode_modulesember-cli-uglifynode_modulesbroccoli-ug
lify-sourcemapindex.js:46:14

如果有人能让我知道原因是什么以及解决方案,那就太好了

当 brocfile.js 被 uglifyJs 解析时,这似乎是一个错误。由于目前在 brcofile 中.js我使用以下行

app.import('bower_components/moment/min/moment.min.js');
app.import('bower_components/jquery-file-upload/js/vendor/jquery.ui.widget.js');
app.import('bower_components/jquery-file-upload/js/jquery.iframe-transport.js');
app.import('bower_components/jquery-file-upload/js/jquery.fileupload.js');

但是,当我使用以下顺序时,

app.import('bower_components/jquery-file-upload/js/vendor/jquery.ui.widget.js');
app.import('bower_components/jquery-file-upload/js/jquery.iframe-transport.js');
app.import('bower_components/jquery-file-upload/js/jquery.fileupload.js');
app.import('bower_components/moment/min/moment.min.js');

错误变为

生成失败。无效映射: {"生成":{"行":74174,"column":-50},"source":"bower_components/jquery-file-upload/js/vendor/jquery .ui.widget.js","original":{"line":1,"column":0},"name":null} 错误: 无效映射: {"生成":{"行":74174,"column":-50},"source":"bower_components/jquery-file-upload/js/vendor /jquery.ui.widget.js","original":{"line":1,"column":0},"name":null} at SourceMapGenerator_validateMapping [as _validateMapping] (C:\wamp\www\PublicMD\EmberMD\Ta\trunk\TextAdminLatestEm berode_modules\ember-cli-uglifyode_modules\broccoli-uglify-sourcemapode_modules\uglify-jsode_modules\source-map\ lib\source-map\source-map-generator.js:272:15)

**********

根据评论建议更新整个 borcfile******

var EmberApp = require('ember-cli/lib/broccoli/ember-app');

var isProduction = ['production', 'hosted-something'].indexOf(process.env.EMBER_ENV) > -1;
var app = new EmberApp({
    fingerprint: {
        enabled: false
    },
    hinting: !isProduction,
    minifyCSS: {
        enabled: isProduction
    },
    minifyJS: {
        enabled: isProduction
    },
    storeConfigInMeta: false,
    tests: !isProduction,
    vendorFiles: {        
        'jquery.js': 'bower_components/jquery/dist/jquery.js',
        'handlebars.js': null,
        'ember.js': {
            'hosted-something':  'bower_components/ember/ember.prod.js'
        },
    },
    wrapInEval: !isProduction
});
if (app.env !== 'hosted-something') {
    app.import('bower_components/bootstrap-go/index.css');
    app.import('bower_components/bootstrap-go-responsive/index.css');
}
app.import('bower_components/moment/min/moment.min.js');
app.import('bower_components/jquery-file-upload/js/vendor/jquery.ui.widget.js');
app.import('bower_components/jquery-file-upload/js/jquery.iframe-transport.js');
app.import('bower_components/jquery-file-upload/js/jquery.fileupload.js');
module.exports = app.toTree();

将以下内容添加到您的 brocfile:

sourcemaps: {
  enabled: !isProduction
}

您收到的错误是由于构建在您运行"生产"构建时尝试生成源映射。

相关内容

  • 没有找到相关文章

最新更新