2017-06-07 19 views
3

Angularインポートから.js接尾辞を削除したいと思います。Angularインポートから.js接尾辞を削除するには

(今実行可能)望まない:import { Example } from './whatever/example.js';

募集:import { Example } from './whatever/example';

を私はsystemjs.config.js内の設定をしないのです疑います。パッケージでこれを追加すること

(function (global) { 
    System.config({ 
    paths: { 
     // paths serve as alias 
     'npm:': '/node_modules/' 
    }, 
    // map tells the System loader where to look for things 
    map: { 
     // our app is within the app folder 
     'app': 'app', 

     // angular bundles 
     // other libraries 

    }, 
    // packages tells the System loader how to load when no filename and/or no extension 
    packages: { 
     app: { 
     defaultExtension: 'js' 
     }, 
     rxjs: { 
     defaultExtension: 'js' 
     } 
    } 
    }); 
})(this); 
+0

あなたは' defaultJSExtensionsを使用して試してみました:パッケージは、今のように見えること

'.': { defaultJSExtensions: 'js' } 

ような。 ..? – Wernerson

+0

@Wernersonはい、それは動作していませんzone.js:2224 GET http:// localhost:8000/app/whatever/example 404(見つかりません) – Olezt

答えて

3

試してみてください。あなたの `System.config(中true`を:

// packages tells the System loader how to load when no filename and/or no extension 
packages: { 
'.': { 
    defaultJSExtensions: 'js' 
}, 
app: { 
    defaultExtension: 'js' 
}, 
rxjs: { 
    defaultExtension: 'js' 
    } 
} 
+0

これは、ありがとうございました! – Olezt

関連する問題