我在我的服务器中使用webpack-dev-middleware来编译这样的javascript:
if (development){
app.use(webpackMiddleware(webpack({
// webpack options
// webpackMiddleware takes a Compiler object as first parameter
// which is returned by webpack(...) without callback.
entry: {
dashboard: path.join(__dirname, 'scripts/dashboard.jsx'),
tasks: path.join(__dirname, 'scripts/tasks.jsx')
},
output: {
path: __dirname + 'dist',
filename: '[name].bundle.js',
// no real path is required, just pass "/"
// but it will work with other paths too.
},
resolve: {
extensions: ['', '.js', '.jsx']
},
module: {
loaders: [
{ test: /\.jsx$/, loader: "jsx" }
]
}
} …Run Code Online (Sandbox Code Playgroud)