TrilonIO / aspnetcore-Vue-starter

*NEW* Asp.net Core & Vue.js (ES6) SPA Starter kit - Vuex, webpack, Web API, Docker, and more! By @TrilonIO
https://www.trilon.io
MIT License
1.22k stars 266 forks source link

Running Vue in development mode #79

Closed navarrorc closed 6 years ago

navarrorc commented 6 years ago

I'm encountering a very odd message after deploying, You are running Vue in development mode.

You can see my deployed site at http://vuejs-dotnet.gear.host/

I see you already have defined the plugin necessary to indicate production mode in the webpack.config.vendor.js file. Do you know what is going on? I can't seem to get rid of this message in production, all files have been minified and optimized, your help would be appreciated.

MarkPieszak commented 6 years ago

Are you running npm run build to make the Prod bundles?

navarrorc commented 6 years ago

@MarkPieszak I have the output of the Web Deploy configuration that I'm using in VS2017. I noticed that the first time it builds the vendor files, isDevBuild is true (see the console.log messages), but in subsequent times the --env.prod argument is being passed. This is done automagically by the deploy process in VS2017.

I also noticed that in the webpack.config.js the following is not there, like it is in the webpack.config.vendor.js

new webpack.DefinePlugin({
                'process.env.NODE_ENV': isDevBuild ? '"development"' : '"production"'
            })

You can see the output of the Web Deploy below: https://gist.github.com/navarrorc/2b3e527e6c0e7c8c5fe7a7653dc055b4

Update: I also deployed the application using the method described at https://docs.microsoft.com/en-us/azure/app-service/app-service-web-get-started-dotnet and I get the same message in the console, you can review this by visiting http://vuejs-dotnet.azurewebsites.net

navarrorc commented 6 years ago

@MarkPieszak I figured it out. I commented out the following line in the webpack.config.js file:

'vue$': 'vue/dist/vue',

vue

You can read more about this at https://vuejs.org/v2/guide/installation.html#Runtime-Compiler-vs-Runtime-only

I don't believe it's necessary and it makes my bundle smaller by removing it. I can create a pull request with this change if you would like. Thanks.

MarkPieszak commented 6 years ago

That might be a super old remnant from when it was all 1.0 stuff! Sure whenever you get a chance to get a PR in I'll merge it in there.

Thanks for investigating!! 👍 👍

navarrorc commented 6 years ago

Sounds good. Just submitted the pull request. Let me know if you have any questions. Thank you.

navarrorc commented 6 years ago

@MarkPieszak I'm wondering was else I need to do in order for you to merge the pull request. It seems like a very important fix that others will benefit from when they get ready to push their projects to production. I would like my fellow developers to use this template but without this fix I can't recommend it. :)

Nordes commented 6 years ago

I did a pull request in order to fix the publish. I don't know if it fixes also this request.

Basically I had an issue with the environment not being set properly to production (The package.json and the Project.csproj didn't have the same configuration). So I harmonized using the NODE_ENV from the process which start the build. Also I fixed the issue where the vendor was compiled twice (once in dev and once in prod).

See pull request #82 (+Few other changes)

navarrorc commented 6 years ago

@Nordes If you didn't remove the vue$': 'vue/dist/vue', line in the webpack.config.js file then the issue will still be there, create a production build and then host the application, open the application in the Chrome browser (or any other browser) and check the browser's console, you will most likely see the running in dev mode message. We don't want this in a production build.

Nordes commented 6 years ago

@navarrorc you're totally right. I missed that while I fixed the publish that was publishing in develop + prod the vendors. I will fix it on my branch and update my pull request.