Skip to content

Commit 6a3b635

Browse files
committed
Add package.json, webconfig and sample js file
1 parent d03e5bd commit 6a3b635

File tree

6 files changed

+147
-3
lines changed

6 files changed

+147
-3
lines changed

VueMVC/Scripts/app/home/index.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import Vue from 'vue'
2+
3+
new Vue({
4+
el: '#app',
5+
data(){
6+
return {
7+
vueMessage: 'Message from Vue'
8+
}
9+
}
10+
})

VueMVC/Views/Home/Index.cshtml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
1-
@{
1+
@using System.Web.Optimization
2+
@{
23
ViewBag.Title = "Home Page";
34
}
45

56
<div id="app">
67
<h3>@ViewBag.Message</h3>
7-
</div>
8+
{{ vueMessage }}
9+
</div>
10+
11+
@section scripts {
12+
@Scripts.Render("~/Scripts/bundle/home.js")
13+
}

VueMVC/VueMVC.csproj

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@
3333
<WarningLevel>4</WarningLevel>
3434
</PropertyGroup>
3535
<ItemGroup>
36+
<Reference Include="Antlr3.Runtime, Version=3.4.1.9004, Culture=neutral, PublicKeyToken=eb42632606e9261f">
37+
<HintPath>..\packages\Antlr.3.4.1.9004\lib\Antlr3.Runtime.dll</HintPath>
38+
</Reference>
3639
<Reference Include="Microsoft.CSharp" />
3740
<Reference Include="Microsoft.Web.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
3841
<HintPath>..\packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll</HintPath>
@@ -54,6 +57,9 @@
5457
<Reference Include="System.Web.Http.WebHost, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
5558
<HintPath>..\packages\Microsoft.AspNet.WebApi.WebHost.5.2.3\lib\net45\System.Web.Http.WebHost.dll</HintPath>
5659
</Reference>
60+
<Reference Include="System.Web.Optimization, Version=1.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
61+
<HintPath>..\packages\Microsoft.AspNet.Web.Optimization.1.1.3\lib\net40\System.Web.Optimization.dll</HintPath>
62+
</Reference>
5763
<Reference Include="System.Web.Services" />
5864
<Reference Include="System.Web.Routing" />
5965
<Reference Include="System.Web.Extensions" />
@@ -78,6 +84,9 @@
7884
<HintPath>..\packages\Microsoft.AspNet.WebPages.3.2.3\lib\net45\System.Web.WebPages.Razor.dll</HintPath>
7985
</Reference>
8086
<Reference Include="System.Xml" />
87+
<Reference Include="WebGrease, Version=1.5.2.14234, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
88+
<HintPath>..\packages\WebGrease.1.5.2\lib\WebGrease.dll</HintPath>
89+
</Reference>
8190
</ItemGroup>
8291
<ItemGroup>
8392
<Compile Include="App_Start\RouteConfig.cs" />
@@ -95,18 +104,24 @@
95104
<Content Include="fonts\glyphicons-halflings-regular.woff" />
96105
<Content Include="fonts\glyphicons-halflings-regular.woff2" />
97106
<Content Include="Global.asax" />
107+
<Content Include="package.json" />
98108
<Content Include="packages.config" />
109+
<Content Include="Scripts\app\home\index.js" />
99110
<Content Include="Views\Home\Index.cshtml" />
100111
<Content Include="Views\Shared\Error.cshtml" />
101112
<Content Include="Views\Shared\_Layout.cshtml" />
102113
<Content Include="Views\Web.config" />
103114
<Content Include="Views\_ViewStart.cshtml" />
104115
<Content Include="Web.config" />
116+
<Content Include="webpack.config.js" />
105117
</ItemGroup>
106118
<ItemGroup>
107119
<Folder Include="Content" />
108120
<Folder Include="Models" />
109-
<Folder Include="Scripts" />
121+
<Folder Include="Scripts\bundle" />
122+
</ItemGroup>
123+
<ItemGroup>
124+
<None Include="packages.config" />
110125
</ItemGroup>
111126
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
112127
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.

VueMVC/package.json

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"name": "vue-mvc",
3+
"version": "1.0.0",
4+
"scripts": {
5+
"dev": "cross-env NODE_ENV=development webpack-dev-server --content-base ./app/webroot/app --inline --hot --port 8086",
6+
"build": "cross-env NODE_ENV=production webpack --progress --hide-modules"
7+
},
8+
"dependencies": {
9+
"bootstrap": "^3.3.7",
10+
"vue": "^2.1.6"
11+
},
12+
"devDependencies": {
13+
"babel-core": "^6.0.0",
14+
"babel-loader": "^6.0.0",
15+
"babel-preset-es2015": "^6.24.1",
16+
"babel-preset-vue-app": "^1.2.0",
17+
"cross-env": "^1.0.6",
18+
"css-loader": "^0.23.1",
19+
"file-loader": "^0.8.5",
20+
"fs": "^0.0.1-security",
21+
"style-loader": "^0.13.1",
22+
"vue-loader": "^9.8.0",
23+
"webpack": "^3.5.4",
24+
"webpack-dev-server": "^2.7.1"
25+
}
26+
}

VueMVC/packages.config

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<packages>
3+
<package id="Antlr" version="3.4.1.9004" targetFramework="net45" />
34
<package id="bootstrap" version="3.3.7" targetFramework="net45" />
45
<package id="jQuery" version="1.9.1" targetFramework="net45" />
56
<package id="Microsoft.AspNet.Mvc" version="5.2.3" targetFramework="net45" />
67
<package id="Microsoft.AspNet.Razor" version="3.2.3" targetFramework="net45" />
8+
<package id="Microsoft.AspNet.Web.Optimization" version="1.1.3" targetFramework="net45" />
79
<package id="Microsoft.AspNet.WebApi" version="5.2.3" targetFramework="net45" />
810
<package id="Microsoft.AspNet.WebApi.Client" version="5.2.3" targetFramework="net45" />
911
<package id="Microsoft.AspNet.WebApi.Core" version="5.2.3" targetFramework="net45" />
1012
<package id="Microsoft.AspNet.WebApi.WebHost" version="5.2.3" targetFramework="net45" />
1113
<package id="Microsoft.AspNet.WebPages" version="3.2.3" targetFramework="net45" />
1214
<package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net45" />
1315
<package id="Newtonsoft.Json" version="6.0.4" targetFramework="net45" />
16+
<package id="WebGrease" version="1.5.2" targetFramework="net45" />
1417
</packages>

VueMVC/webpack.config.js

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
var path = require('path')
2+
var webpack = require('webpack')
3+
var fs = require('fs')
4+
5+
var appBasePath = './Scripts/app/'
6+
7+
var jsEntries = {}
8+
// We search for index.js files inside basePath folder and make those as entries
9+
fs.readdirSync(appBasePath).forEach(function (name) {
10+
var indexFile = appBasePath + name + '/index.js'
11+
if (fs.existsSync(indexFile)) {
12+
jsEntries[name] = indexFile
13+
}
14+
})
15+
16+
module.exports = {
17+
entry: jsEntries,
18+
output: {
19+
path: path.resolve(__dirname, './Scripts/bundle/'),
20+
publicPath: '/Scripts/bundle/',
21+
filename: '[name].js'
22+
},
23+
resolve: {
24+
extensions: ['.js', '.vue', '.json'],
25+
alias: {
26+
'vue$': 'vue/dist/vue.esm.js',
27+
'@': path.join(__dirname, appBasePath)
28+
}
29+
},
30+
module: {
31+
loaders: [
32+
{
33+
test: /\.vue$/,
34+
loader: 'vue-loader'
35+
},
36+
{
37+
test: /\.js$/,
38+
loader: 'babel-loader',
39+
exclude: /node_modules/
40+
},
41+
{
42+
test: /\.css$/,
43+
loader: 'style-loader!css-loader'
44+
},
45+
{
46+
test: /\.(eot|svg|ttf|woff|woff2)(\?\S*)?$/,
47+
loader: 'file-loader'
48+
},
49+
{
50+
test: /\.(png|jpe?g|gif|svg)(\?\S*)?$/,
51+
loader: 'file-loader',
52+
query: {
53+
name: '[name].[ext]?[hash]'
54+
}
55+
}
56+
]
57+
},
58+
devServer: {
59+
proxy: {
60+
'*': {
61+
target: 'http://localhost:5001',
62+
changeOrigin: true
63+
}
64+
}
65+
},
66+
devtool: '#eval-source-map'
67+
}
68+
69+
if (process.env.NODE_ENV === 'production') {
70+
module.exports.devtool = '#source-map'
71+
// http://vue-loader.vuejs.org/en/workflow/production.html
72+
module.exports.plugins = (module.exports.plugins || []).concat([
73+
new webpack.DefinePlugin({
74+
'process.env': {
75+
NODE_ENV: '"production"'
76+
}
77+
}),
78+
new webpack.optimize.UglifyJsPlugin({
79+
compress: {
80+
warnings: false
81+
}
82+
})
83+
])
84+
}

0 commit comments

Comments
 (0)