Microsoft Azure托管|Nodejs |webpack无法编译文件 [英] Microsoft Azure hosting | Nodejs | file doesn't get compiled by webpack

查看:53
本文介绍了Microsoft Azure托管|Nodejs |webpack无法编译文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用nodejs构建一个Web应用程序.它可以在我的本地计算机上编译并运行良好,但是当我尝试在Azure上托管它时,webpack似乎会引起问题.

I'm trying to build a webapp using nodejs. It compiles and runs fine on my local machine but when I try to host it on Azure, webpack seems to cause problem.

//webpack.config.js

var config = {
   entry: './main.js',

   output: {
      path:'/',
      filename: 'index.js',
   },

   devServer: {
      // inline: true,
      // port: 8080
   },

   module: {
      loaders: [
         {
            test: /\.jsx?$/,
            exclude: /node_modules/,
            loader: 'babel-loader',

            query: {
               presets: ['es2015', 'react']
            }
         }
      ]
   }
}

module.exports = config;

这是文件层次结构:

这是Chrome Dev工具中用于本地计算机的源"标签.我在这里注意到index.js按照配置文件中的指定进行编译.

This is the sources tab in Chrome Dev tool for local machine. I notice here the index.js get compiled as specified in the config file.

然后我只是使用git将源放置在服务器上.这是我从服务器获得的响应:

Then I just place the source on the server using git. This is the response I get from the server:

这是托管服务器的来源"标签.

This is the sources tab for the hosting server.

我怀疑这可能是因为解释本地计算机和主机上的目录存在差异吗?我正在使用MacOS.

I suspect that it could be because there is difference in interpreting the directories on my local machine and the host?! I'm using MacOS.

推荐答案

基本上,在部署到Azure生产服务器之前,您首先需要编译WebPack应用程序.但是,您也可以利用自定义部署脚本来安装Node.js.模块并运行自定义脚本,以在Azure部署任务期间在Azure Web Apps上构建WebPack应用程序.有关详细步骤,请在StackOverflow上查看这篇文章.

Basically, you would need to compile your WebPack application first before deploying to Azure production server. However, you can also leverage Custom Deployment Script to install Node.js modules and run custom scripts to build your WebPack application on Azure Web Apps during the Azure Deployment task. For detailed steps, please check out this post on StackOverflow.

这篇关于Microsoft Azure托管|Nodejs |webpack无法编译文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆