I have an ASP.Net Core MVC with razor views that uses VueJs2 when it needs to be more complex.

I want to have a js file per view.

My folder structure is like that:

├ Controllers\HomeController.cs (with actions Index & Details)
├ Scripts\Home\index.ts
├ Scripts\Home\details.ts
├ Views\Home\Index.cshtml
├ Views\Home\Details.csthml
├ wwwroot\lib\vue
├ wwwroot\js\Home\index.js (generated with typescript)
├ wwwroot\js\Home\details.js (generated with typescript)
├ tsconfig.json

Here is my tsconfig.json

  "compilerOptions": {
    "noImplicitAny": false,
    "noEmitOnError": true,
    "removeComments": false,
    "sourceMap": true,
    "target": "es5",
    "outDir": "wwwroot/js",
    "rootDir": "Scripts",
    "allowSyntheticDefaultImports": true,
    "lib": [
  "include": [
  "compileOnSave": true

My index.ts file

import Vue from 'vue'

var app = new Vue({
    el: '#app',
    data: {
        message: 'Hello Vue!'

And the generated file:

"use strict";
var vue_1 = require("vue");
var app = new vue_1.default({
    el: '#app',
    data: {
        message: 'Hello Vue!'
//# sourceMappingURL=index.js.map

In my Index.cshtml I load the js file but I have this require instruction that is not working in my browsers.

How to have this js files working within a browser?

Related posts

Recent Viewed