• <legend id='MOrQz'><style id='MOrQz'><dir id='MOrQz'><q id='MOrQz'></q></dir></style></legend>

    <small id='MOrQz'></small><noframes id='MOrQz'>

      <i id='MOrQz'><tr id='MOrQz'><dt id='MOrQz'><q id='MOrQz'><span id='MOrQz'><b id='MOrQz'><form id='MOrQz'><ins id='MOrQz'></ins><ul id='MOrQz'></ul><sub id='MOrQz'></sub></form><legend id='MOrQz'></legend><bdo id='MOrQz'><pre id='MOrQz'><center id='MOrQz'></center></pre></bdo></b><th id='MOrQz'></th></span></q></dt></tr></i><div id='MOrQz'><tfoot id='MOrQz'></tfoot><dl id='MOrQz'><fieldset id='MOrQz'></fieldset></dl></div>

      <tfoot id='MOrQz'></tfoot>

        • <bdo id='MOrQz'></bdo><ul id='MOrQz'></ul>

        aspnet core如何在deploy上构建webpack

        时间:2023-05-28
      1. <tfoot id='47BUO'></tfoot>

          <bdo id='47BUO'></bdo><ul id='47BUO'></ul>

          <i id='47BUO'><tr id='47BUO'><dt id='47BUO'><q id='47BUO'><span id='47BUO'><b id='47BUO'><form id='47BUO'><ins id='47BUO'></ins><ul id='47BUO'></ul><sub id='47BUO'></sub></form><legend id='47BUO'></legend><bdo id='47BUO'><pre id='47BUO'><center id='47BUO'></center></pre></bdo></b><th id='47BUO'></th></span></q></dt></tr></i><div id='47BUO'><tfoot id='47BUO'></tfoot><dl id='47BUO'><fieldset id='47BUO'></fieldset></dl></div>

            <tbody id='47BUO'></tbody>

                <small id='47BUO'></small><noframes id='47BUO'>

                  <legend id='47BUO'><style id='47BUO'><dir id='47BUO'><q id='47BUO'></q></dir></style></legend>
                  本文介绍了aspnet core如何在deploy上构建webpack的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  限时送ChatGPT账号..

                  我有一个带有 vue.js 部分的 aspnet 核心应用程序,我使用 webpack 构建它并且一切正常.现在我搜索一个解决方案来创建一个生产构建,创建我的 vue 包的缩小版本并在生产模式下运行 vue(没有 console.logs),这是我在我的 webpack.config 中设置的喜欢:

                  I have a aspnet core application with a vue.js part, which I build with webpack and everything works fine. Now I search a solution to create a productionbuild with it, to create a minified version of my vue bundle and to run vue in production mode (without console.logs), which I set in my webpack.config like:

                  if (process.env.NODE_ENV === 'production') {
                      module.exports.plugins = [
                          new webpack.DefinePlugin({
                              'process.env': {
                                  NODE_ENV: '"production"'
                              }
                          }),
                          new webpack.optimize.UglifyJsPlugin({
                              compress: {
                                  warnings: false
                              }
                          })
                      ]
                  } else {
                      module.exports.devtool = '#source-map'
                  }
                  

                  但是 process.env.NODE_ENV 当我通过 gulp 对其进行 webpack 时总是未定义.比我尝试在 startup.cs 中将 Microsoft.AspNetCore.SpaServices 与这一行一起使用:

                  but process.env.NODE_ENV is always undefined when I webpack it via gulp. Than I tried to use Microsoft.AspNetCore.SpaServices with this line in startup.cs:

                  public void Configure(IApplicationBuilder app, IHostingEnvironment env)
                  {
                  ...
                      if(env.IsDevelopment())
                          app.UseWebpackDevMiddleware();
                  ...
                  }
                  

                  这也很好,就像我的 gulp 配置和 process.env.NODE_ENV 属性设置为 'development'

                  This works also fine like my gulp configuration and process.env.NODE_ENV property is set to 'development'

                  现在我尝试在 VS 2017 中创建生产版本(Build -> Publish Projectname),但没有运行 webpack 任务.

                  Now I try to create a production build in VS 2017 (Build -> Publish Projectname), but no webpack task runs.

                  所以我尝试在我的 *.csproj 中添加它:

                  So i tried to add this in my *.csproj:

                  <Target Name="PrepublishScript" BeforeTargets="PrepareForPublish">
                      <Exec Command="npm run build" />
                  </Target>
                  

                  这会引发错误:命令npm run build"以代码 1 退出.

                  this throws the error: The command "npm run build" exited with code 1.

                  现在我没有其他想法来解决它,希望任何人都可以帮助我.谢了!

                  Now I'm out of other ideas to resolve it and hope that anyone can help me. THX!

                  推荐答案

                  解决方法:在 .csproj:

                  <Target Name="PrepublishScript" BeforeTargets="PrepareForPublish">
                      <Exec Command="npm install" />
                      <Exec Command="npm run production" />
                  </Target>
                  

                  并在我的 package.json 中添加脚本:

                  and adding scripts in my package.json:

                  "scripts": {
                      "dev": "cross-env NODE_ENV=development webpack --hide-modules",
                      "production": "cross-env NODE_ENV=production webpack --hide-modules"
                  }
                  

                  这需要 webpack &cross-env 包(以及 webpack 期间使用的所有其他包)已安装 &一个工作的 webpack.config.js

                  this needs webpack & cross-env packages (and all other used packages during webpack) installed & a working webpack.config.js

                  询问是否有人对我的 webpack.config.js 或其他代码感兴趣

                  Ask if someone is interrested to my webpack.config.js or some other code

                  这篇关于aspnet core如何在deploy上构建webpack的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:缩进的 Sass 语法不适用于 node-sass 和 gulp-sass 下一篇:将 gulp.start 函数迁移到 Gulp v4

                  相关文章

                  最新文章

                  <legend id='qtrcl'><style id='qtrcl'><dir id='qtrcl'><q id='qtrcl'></q></dir></style></legend>
                • <tfoot id='qtrcl'></tfoot>
                  • <bdo id='qtrcl'></bdo><ul id='qtrcl'></ul>
                  <i id='qtrcl'><tr id='qtrcl'><dt id='qtrcl'><q id='qtrcl'><span id='qtrcl'><b id='qtrcl'><form id='qtrcl'><ins id='qtrcl'></ins><ul id='qtrcl'></ul><sub id='qtrcl'></sub></form><legend id='qtrcl'></legend><bdo id='qtrcl'><pre id='qtrcl'><center id='qtrcl'></center></pre></bdo></b><th id='qtrcl'></th></span></q></dt></tr></i><div id='qtrcl'><tfoot id='qtrcl'></tfoot><dl id='qtrcl'><fieldset id='qtrcl'></fieldset></dl></div>

                    <small id='qtrcl'></small><noframes id='qtrcl'>