Coder Social home page Coder Social logo

ramaxin / aspdotnet-vuejs Goto Github PK

View Code? Open in Web Editor NEW

This project forked from hvpaiva/aspdotnet-vuejs

0.0 1.0 0.0 78 KB

ASP.NET Core and VueJs Template

Home Page: https://www.nuget.org/packages/aspdotnet-vuejs/

License: MIT License

JavaScript 45.27% HTML 6.36% Vue 28.70% CSS 0.91% C# 17.06% Dockerfile 1.70%

aspdotnet-vuejs's Introduction

NuGet Build status

Dotnet Core 2.2 + VueJs

This project main idea is to provide an easy way to start a new project using .Net Core WebAPI in server side and VueJs in the client side. For this goal, we setup the main configuration to enable this integration using some utilities as hot reloading and some frontend libraries as Element-UI and FontAwesome.

Our goal is to provide a simple SPA with minimum dependencies and performance issues. The VueJs is configured with Vuex and Vue Router, but this can be removed if you don't feel it meets your requirement. The same goes for the component library. In this template, we also provide examples with the main functionalits.

This template is inspired and adapted from Mark Pieszak's project and Nordes' project.

Table Of Contents

Technology inside

  • .Net Core 2.2
  • VueJs
  • Webpack 4
  • Element UI
  • Babel
  • Vuex
  • Vue-router
  • Eslint (airbnb + vuejs-recomended)
  • Swagger *
  • Vue-i18n *
  • Vee-validate *

* Work In Progress. Available in future releases.

Installation

To download and install the template, just type:

> dotnet new -i aspdotnet-vuejs

You can see a list of installed templates by using the dotnet new -l command.

Then to create your project you will simply use the command bellow in the directory:

> dotnet new vue

This will automatically run dotnet restore. But it can be changed in template configurations. See dotnet new vue -h before using the previous command.

The solution and project name will be the name of the directory.

Update your installation

To update your installation, you will just need to repeat the installation process. As long as the version number are not equals, you won't have any unexpected behaviour.

Uninstallation

Type the following command from the shell:

> dotnet new -u aspdotnet-vuejs

Develop

To start developing your application, just use the .Net CLI command:

 > dotnet run YourAplication.csproj

You can just type dotnet run in the project directory or configure your IDE to run. In this last case just don't forget to pass the ASPNETCORE_ENVIRONMENT=Development environment variable.

This will also run all node dependencies like npm i.

The application will be started in Development mode with hot reloading enabled at https://localhost:5001 and http://localhost:5000.

Publishing your application

Before publishing

You need to ensure that your wwwroot is empty before starting the process.

Publishing

Simply use the normal way of publishing using .Net Core CLI

> dotnet publish YourProject.csproj -c release -o ./publish/

You can also add all the other parameter from the dotnet cli. Please visit the MSDN site to know more about it.

This will do a rebuild of your project and then after it will use the special target to rebuild your client (vuejs) in production mode.

Extra if you use NginX

If you are publishing behind a NginX server, you might need more configuration.

Let's say you have your base site http://www.example.com and that in your NginX configuration you would like to have your dotnet app within http://www.example.com/myApp. You will need in such a scenario to set the base uri for the index.html. Instead of doing that manually between development and production, you have the file ./build/base.prod.config.js which contains a possible override.

Simply set your override like the following:

module.exports = {
  baseUriPath: '/myApp/'
}

When you will publish next time, the path will then be taken into account and it will sets automatically the base uri path.

Docker

The project already add some docker container available through the Docker Hub. You can pull the image if you want. It will make the sample available locally. The image is using the Alpine version so it only uses a small footprint.

Docker - Build yourself

Since containers in docker are quite popular, a Dockerfile is also included within the template root folder. Don't forget the .dockerignore where some files are being ignored in order to avoid some unwanted file to be copied before publishing.

Ensure that you have Docker installed.

Some Automation

Kestrel serving using Gzip compression

The code is having built-in the Gzip compression on the HTTPs. It's good to use that code especially if you use Kestrel. Otherwise, if you use IIS, please remove that specific code found in the Startup.cs. Normally, IIS offer it's own compression module which is more performant.

Base components

There's some automation regarding the Components available within ./ClientApp/components/**/*. All the file starting with the keyword base are going to be declared as global and the name of the component to be used anywhere will be defined in snake case without the base keyword.

Example: baseHelloWorld will be registered as hello-world and you are going to be able to use it in your Vue Template.

<template>
  <div>
    <hello-world /> works!
  </div>
</template>

There's a real example within the project for the card component for each page. The name of the component is baseCard.vue.

Webpack build

The css is not generated while you are in development mode. They are going to be created only when you will use the dotnet publish command or as an alternative, you can also go and type npm run build -- --prod which will launch the production build with the minification and extraction of the files.

Important: Currently, webpack clean the entire wwwroot folder within the .Net project. So, if you have static files, move them within the ./ClientApp/static/ folder.

Look'n feel

Element UI

To help make the development faster, we provide the installation of the component library Element-UI. The documentation of this library can be founded in his site.

It can be removed normally in main.js if you don't need.

License

License MIT

aspdotnet-vuejs's People

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.