Skip to content

Commit 701c587

Browse files
committed
v1.0.0 Improved support for images and fonts | Added automatic reading of app.js or app.ts entry files | Updated readme
1 parent f6a5309 commit 701c587

File tree

6 files changed

+104
-27
lines changed

6 files changed

+104
-27
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
The repository contains template using Vue.js, Vuex, Vue router, TypeScript, Bulma, SASS and Jest. It integrates Vue into AspNetCore MVC and showcases how to use Vue with it's entire ecosystem in .NET as a multipage (multiple mini SPA's) application. The template can also be used as a complete single page application but you should consider using [Vue cli](https://cli.vuejs.org/) for this as it is a more flexible and advanced solution.
44

5+
> **No TypeScript**: Template completely supports usage without TypeScript. You can use plain js if you don't have the need for or don't want to use TypeScript.
6+
7+
**Medium:** [Multi-page .NET Core with Vue.js, TypeScript, Vuex, Vue router, Bulma, Sass, Jest and Webpack 4](https://medium.com/@danijelhdev/multi-page-net-core-with-vue-js-typescript-vuex-vue-router-bulma-sass-and-webpack-4-efc7de83fea4)
8+
59
---
610

711
<p style="text-align:center">

aspnetcore-vue-typescript-template.nuspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<package xmlns="http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd">
33
<metadata>
44
<id>AspNetCore.Vue.TypeScript.Template</id>
5-
<version>0.3.1</version>
5+
<version>1.0.0</version>
66
<description>
77
Template integrating Vue.js with ASP.NET Core MVC application. Features Vue, Vuex, Vue router, TypeScript, Bulma, Sass, Jest and Webpack 4.
88
</description>
@@ -14,7 +14,7 @@
1414
<packageType name="Template" />
1515
</packageTypes>
1616
<requireLicenseAcceptance>false</requireLicenseAcceptance>
17-
<releaseNotes>0.3.1 release.</releaseNotes>
17+
<releaseNotes>1.0.0 release.</releaseNotes>
1818
</metadata>
1919
<files>
2020
<file

content/AspNetCore.VueJs/VueApp/idontneedtypescript/views/ModuleInfo.vue

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,6 @@
2424
<li>
2525
Rename all <strong>.ts</strong> files to <strong>.js</strong> and remove types from code.
2626
</li>
27-
<li>
28-
In <strong>webpack.config.js</strong> import <strong>.js</strong> entry files
29-
</li>
3027
<li>
3128
In <strong>webpack.config.js</strong> remove <strong>ts-loader</strong> and remove <strong>".ts"</strong> extension
3229
</li>

content/AspNetCore.VueJs/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
"jest": "23.6.0",
5050
"jest-serializer-vue": "2.0.2",
5151
"node-sass": "4.11.0",
52+
"url-loader":"1.1.2",
5253
"resolve-url-loader": "3.0.0",
5354
"sass-loader": "7.1.0",
5455
"style-loader": "0.23.1",

content/AspNetCore.VueJs/webpack.config.js

Lines changed: 94 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
"use strict";
22

3+
const fs = require('fs')
34
const path = require("path");
45
const webpack = require("webpack");
56
const { VueLoaderPlugin } = require("vue-loader");
@@ -11,31 +12,44 @@ const OptimizeCssAssetsPlugin = require('optimize-css-assets-webpack-plugin');
1112

1213
// Custom variables
1314
let isProduction = false;
14-
const applicationBasePath = "VueApp";
15+
const applicationBasePath = "./VueApp/";
1516

1617
// Plugins
1718
const extractSassPlugin = new ExtractTextPlugin({
1819
filename: "css/[name]/main.css",
1920
allChunks: true
2021
});
2122

23+
// We search for app.js or app.ts files inside VueApp/{miniSpaName} folder and make those as entries. Convention over configuration
24+
var appEntryFiles = {}
25+
fs.readdirSync(applicationBasePath).forEach(function (name) {
26+
27+
let spaEntryPoint = applicationBasePath + name + '/app.ts'
28+
29+
if (fs.existsSync(spaEntryPoint)) {
30+
appEntryFiles[name] = spaEntryPoint
31+
}
32+
33+
spaEntryPoint = applicationBasePath + name + '/app.js'
34+
if (fs.existsSync(spaEntryPoint)) {
35+
appEntryFiles[name] = spaEntryPoint
36+
}
37+
38+
})
39+
40+
// Add main site.scss file with Bulma(or any other source by choice)
41+
appEntryFiles["vendor"] = [
42+
path.resolve(__dirname, "VueApp/common/design/site.scss"),
43+
]
44+
2245
module.exports = function (env, argv) {
2346

2447
if (argv.mode === "production") {
2548
isProduction = true;
2649
}
2750

2851
return {
29-
entry: {
30-
template: path.resolve(__dirname, applicationBasePath + "/template/app.ts"),
31-
iceandfire: path.resolve(__dirname, applicationBasePath + "/iceandfire/app.ts"),
32-
idontneedtypescript: path.resolve(__dirname, applicationBasePath + "/idontneedtypescript/app.js"),
33-
vendor: [
34-
35-
path.resolve(__dirname, "VueApp/common/design/site.scss"),
36-
37-
]
38-
},
52+
entry: appEntryFiles,
3953
output: {
4054
path: path.resolve(__dirname, "wwwroot/dist"),
4155
filename: "js/[name]/bundle.js",
@@ -46,7 +60,7 @@ module.exports = function (env, argv) {
4660
extensions: [".ts", ".js", ".vue", ".json", "scss", "css"],
4761
alias: {
4862
vue$: "vue/dist/vue.esm.js",
49-
"@": path.join(__dirname, "./" + applicationBasePath + "/")
63+
"@": path.join(__dirname, applicationBasePath)
5064
}
5165
},
5266
devtool: "source-map",
@@ -57,6 +71,7 @@ module.exports = function (env, argv) {
5771
},
5872
module: {
5973
rules: [
74+
/* config.module.rule('vue') */
6075
{
6176
test: /\.vue$/,
6277
loader: "vue-loader",
@@ -68,12 +83,14 @@ module.exports = function (env, argv) {
6883
}
6984
}
7085
},
86+
/* config.module.rule('js') */
7187
{
7288
test: /\.js$/,
7389
exclude: /(node_modules|bower_components)/,
7490
loader: "babel-loader",
7591
exclude: /node_modules/,
7692
},
93+
/* config.module.rule('ts') */
7794
{
7895
test: /\.ts$/,
7996
loader: "ts-loader",
@@ -82,6 +99,7 @@ module.exports = function (env, argv) {
8299
transpileOnly: true
83100
}
84101
},
102+
/* config.module.rule('sass') */
85103
{
86104
test: /\.scss$/,
87105
use: extractSassPlugin.extract({
@@ -103,22 +121,76 @@ module.exports = function (env, argv) {
103121
fallback: "style-loader"
104122
})
105123
},
124+
/* config.module.rule('css') */
106125
{
107126
test: /\.css$/,
108127
loader: "css-loader"
109128
},
129+
/* config.module.rule('images') */
110130
{
111-
test: /.(ttf|otf|eot|svg|woff(2)?)(\?[a-z0-9]+)?$/,
112-
use: [
113-
{
114-
loader: "file-loader",
115-
options: {
116-
name: "[name].[ext]",
117-
outputPath: "css/",
118-
publicPath: "/dist/"
119-
}
131+
test: /\.(png|jpe?g|gif|webp)(\?.*)?$/,
132+
use: [
133+
{
134+
loader: 'url-loader',
135+
options: {
136+
limit: 4096,
137+
fallback: {
138+
loader: 'file-loader',
139+
options: {
140+
name: 'img/[name].[hash:8].[ext]'
141+
}
120142
}
121-
]
143+
}
144+
}
145+
]
146+
},
147+
/* config.module.rule('svg') */
148+
{
149+
test: /\.(svg)(\?.*)?$/,
150+
use: [
151+
{
152+
loader: 'file-loader',
153+
options: {
154+
name: 'img/[name].[hash:8].[ext]'
155+
}
156+
}
157+
]
158+
},
159+
/* config.module.rule('media') */
160+
{
161+
test: /\.(mp4|webm|ogg|mp3|wav|flac|aac)(\?.*)?$/,
162+
use: [
163+
{
164+
loader: 'url-loader',
165+
options: {
166+
limit: 4096,
167+
fallback: {
168+
loader: 'file-loader',
169+
options: {
170+
name: 'media/[name].[hash:8].[ext]'
171+
}
172+
}
173+
}
174+
}
175+
]
176+
},
177+
/* config.module.rule('fonts') */
178+
{
179+
test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/i,
180+
use: [
181+
{
182+
loader: 'url-loader',
183+
options: {
184+
limit: 4096,
185+
fallback: {
186+
loader: 'file-loader',
187+
options: {
188+
name: 'fonts/[name].[hash:8].[ext]'
189+
}
190+
}
191+
}
192+
}
193+
]
122194
}
123195
]
124196
},

package-lock.json

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)