2017-01-29 5 views
2

これは私のbabel-options.jsファイルの内容です。私のアプリが読み込みに失敗し、コンソール`async/await`関数を正しく動作させるための正しいbabel設定は何ですか?

のいずれかのエラーが発生することなく、私も[['latest', { loose: true, modules: modules }], 'stage-3]にプリセットを更新しようとしたが、がぶ飲みはlatest

babel-options.js

var path = require('path'); 
var paths = require('./paths'); 

module.exports = function(modules) { 
    return { 
    filename: '', 
    filenameRelative: '', 
    sourceMap: true, 
    sourceRoot: '', 
    moduleRoot: path.resolve('src').replace(/\\/g, '/'), 
    moduleIds: false, 
    comments: false, 
    compact: false, 
    code: true, 
    presets: [ ['es2015', { loose: true, modules: modules }], 'stage-1'], 
    plugins: [ 
     'syntax-flow', 
     'transform-decorators-legacy', 
     'transform-flow-strip-types', 
     'transform-async-to-generator' 
    ] 
    }; 
}; 
への相対パスを見つけることができない不満私が使用している

スケルトンパック:https://github.com/aurelia/skeleton-navigation/tree/master/skeleton-esnext

サンプルbabel-options.js https://github.com/aurelia/skeleton-navigation/blob/master/skeleton-esnext/build/babel-options.js

+1

設定を更新したときに 'bpm-preset-latest'をインストールしましたか? – loganfsmyth

+0

@loganfsmythはい – lasec0203

答えて

0

webpackとasync/awaitで動作するbabelを使用しています。これは私のwebpack.config.babel.jsです:

var path = require('path'); 
var webpack = require('webpack'); 
var VersionFile = require('webpack-version-file-plugin'); 
var wwwPath = path.join(__dirname, 'public/dist'); 

module.exports = { 
entry: { 
    preload: [ 'babel-polyfill', './src/main.js' ] 
}, 
cache: true, 
debug: true, 
devtool: 'source-map', 
output: { 
    path: path.join(__dirname, 'public/dist'), 
    publicPath: '../public/dist/', 
    filename: '[name].js', 
    chunkFilename: '[id].js', 
    libraryTarget: 'var', 
    library: 'ViewerEntryPoint' 
}, 

resolve: { 
    root: [ 
     path.join(__dirname, '..', 'app', 'src'), 
    ], 
    alias: { 
     jquery$: 'jquery/jquery', 
     lodash$: 'lodash/lodash', 
     _$: 'lodash/lodash' 
    } 
}, 

resolveLoader: { 
    root: [ 
     path.join(__dirname, 'node_modules') 
    ] 
}, 

module: { 
    loaders: [ 
     { 
      loader: "babel-loader", 

      // Skip any files outside of your project's `src` directory 
      include: [ 
       path.resolve(__dirname, "src"), 
      ], 

      // Only run `.js` and `.jsx` files through Babel 
      test: /\.jsx?$/, 

      // Options to configure babel with 
      query: { 
       plugins: [ 'transform-runtime' ], 
       presets: [ 'es2015', 'stage-0' ] //, 'react'], 
      } 
     }, 

     { test: /\.css$/, loaders: [ 'style/useable', 'css' ] }, 
     { test: /[\/\\]jquery\.js$/, loader: 'exports?window.$' } 
    ], 
    noParse: [ 
     /[\/\\]jquery\.js$/ 
    ] 
}, 
plugins: [ 
    //new Clean(['dist']), 
    new webpack.HotModuleReplacementPlugin(), 
    new webpack.NoErrorsPlugin(), 
    new webpack.SourceMapDevToolPlugin({ 
     test: /\.js$/, 
     moduleFilenameTemplate: '[absolute-resource-path]', 
     fallbackModuleFilenameTemplate: '[absolute-resource-path]?[hash]', 
     filename: "[file].map", 
     sourceRoot: '/src/' 
    }), 
    new VersionFile({ 
     packageFile: path.join(__dirname, 'package.json'), 
     template: path.join(__dirname, 'version.ejs'), 
     outputFile: path.join(wwwPath, 'version.json') 
    }) 
] 
}; 
関連する問題