2017-01-04 9 views
2

aspnet에서 반응하는 응용 프로그램을 얻으려고하고 있으며 webpack을 사용하고 있습니다.react.js aspnet이있는 웹팩 - 'global'및 'exports'가 정의되지 않았습니다.

이 내 웹팩 설정

var path = require('path'); 
var webpack = require('webpack'); 
var HtmlWebpackPlugin = require('html-webpack-plugin'); 
var pkg = require('./package.json'); 

// bundle dependencies in separate vendor bundle 
var vendorPackages = Object.keys(pkg.dependencies).filter(function (el) { 
return el.indexOf('font') === -1; // exclude font packages from vendor bundle 
}); 

/* 
* Default webpack configuration for development 
*/ 
var config = { 
devtool: 'eval-source-map', 
cache: true, 
entry: { 
    main: path.join(__dirname, "app", "App.js"), 
    vendor: vendorPackages 
}, 
output: { 
    path: path.join(__dirname, "js"), 
    filename: '[name].js', 
    sourceMapFilename: "[file].map" 
}, 

resolve: { 
    modulesDirectories: ['node_modules'], alias: {}, extensions: ['', '.jsx', '.js'] 
}, 
plugins: [ 
    new webpack.OldWatchingPlugin(), //needed to make watch work. see http://stackoverflow.com/a/29292578/1434764 
    new webpack.optimize.CommonsChunkPlugin(/* chunkName= */"vendor", /* filename= */"vendor.js") 
], 
resolveLoader: { 
    'fallback': path.join(__dirname, 'node_modules') 
}, 
module: { 
loaders: [{ 
    test: /\.js$/, 
    exclude: /node_modules/, 
    loader: 'babel', 
    query: { 
     presets: ['es2015','react'] 
    } 
}, { 
    test: /\.css$/, 
    loader: 'style!css!' 
}] 
} 
} 

/* 
* If bundling for production, optimize output 
*/ 
if (process.env.NODE_ENV === 'production') { 
config.devtool = false; 

config.plugins = [ 
    new webpack.optimize.OccurenceOrderPlugin(), 

    new webpack.optimize.UglifyJsPlugin({ 
     comments: false, 
     compress: { warnings: false} 
    }), 
    new webpack.DefinePlugin({ 
     'process.env': {NODE_ENV: JSON.stringify('production')} 
    }) 
]; 
}; 

module.exports = config; 

내가 페이지에 액세스하려고 할 때 콘솔에서이 두 오류를 얻고있다.

SCRIPT5009는 '글로벌'는 정의되지 vendor.js

SCRIPT5009 (42739,2) '수출'정의되지 mobilelobbyapp.js (1,1)

내가 할 수있는 이 문제를 해결하는 방법을 찾아 내지 못합니다. 나는 웹팩에서 보낸 JS 파일이 광산

exports.ids = [0]; 
exports.modules = { 

답변

0

나는이 게시물 'global' undefined after running webpack을 발견하고 내가 fixSCRIPT5009 수있었습니다을 가진 파일의 시작 부분에

webpackJsonp([0],{ 

을 가지고있는 잘 동작하는 예제에 통보했다 : ,

plugins: [ 
    new webpack.OldWatchingPlugin(), //needed to make watch work. see  https://stackoverflow.com/a/29292578/1434764 
    new webpack.optimize.CommonsChunkPlugin(/* chunkName= */"vendor", /* filename= */"vendor.js"), 
    new webpack.DefinePlugin({ global: {} }), 
], 
,745 '글로벌'

새로운 webpack.DefinePlugin ({{}} 글로벌)를 추가하여 정의 vendor.js 인

다음은 내가 SCRIPT5009 고정 '수출은'내 webpack.config에서

target: 'node', 

을 제거하여 정의되지