Skip to content

Commit c0bc8df

Browse files
committed
Update VueJsAspNetCore sample project using vue@2.2.1
1 parent ccc0189 commit c0bc8df

30 files changed

+236
-148
lines changed

src/VueJsAspNetCoreSample/.babelrc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
{
22
"presets": [
3-
["es2015", { "modules": false }],
3+
["latest", {
4+
"es2015": { "modules": false }
5+
}],
46
"stage-2"
57
],
68
"plugins": ["transform-runtime"],
79
"comments": false,
810
"env": {
911
"test": {
12+
"presets": ["latest", "stage-2"],
1013
"plugins": [ "istanbul" ]
1114
}
1215
}

src/VueJsAspNetCoreSample/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
node_modules/
33
dist/
44
npm-debug.log
5+
yarn-error.log
56
test/unit/coverage
67
test/e2e/reports
78
selenium-debug.log
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// https://github.com/michael-ciniawsky/postcss-load-config
2+
3+
module.exports = {
4+
"plugins": {
5+
// to edit target browsers: use "browserlist" field in package.json
6+
"autoprefixer": {}
7+
}
8+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# vuejs-sample
2+
3+
> A Vue.js project
4+
5+
## Build Setup
6+
7+
``` bash
8+
# install dependencies
9+
npm install
10+
11+
# serve with hot reload at localhost:8080
12+
npm run dev
13+
14+
# build for production with minification
15+
npm run build
16+
17+
# build for production and view the bundle analyzer report
18+
npm run build --report
19+
20+
# run unit tests
21+
npm run unit
22+
23+
# run e2e tests
24+
npm run e2e
25+
26+
# run all tests
27+
npm test
28+
```
29+
30+
For detailed explanation on how things work, checkout the [guide](http://vuejs-templates.github.io/webpack/) and [docs for vue-loader](http://vuejs.github.io/vue-loader).
Lines changed: 18 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,35 @@
1-
// https://github.com/shelljs/shelljs
21
require('./check-versions')()
32

43
process.env.NODE_ENV = 'production'
54

65
var ora = require('ora')
6+
var rm = require('rimraf')
77
var path = require('path')
88
var chalk = require('chalk')
9-
var shell = require('shelljs')
109
var webpack = require('webpack')
1110
var config = require('../config')
1211
var webpackConfig = require('./webpack.prod.conf')
1312

1413
var spinner = ora('building for production...')
1514
spinner.start()
1615

17-
var assetsPath = path.join(config.build.assetsRoot, config.build.assetsSubDirectory)
18-
shell.rm('-rf', assetsPath)
19-
shell.mkdir('-p', assetsPath)
20-
shell.config.silent = true
21-
shell.cp('-R', 'static/*', assetsPath)
22-
shell.config.silent = false
23-
24-
webpack(webpackConfig, function (err, stats) {
25-
spinner.stop()
16+
rm(path.join(config.build.assetsRoot, config.build.assetsSubDirectory), err => {
2617
if (err) throw err
27-
process.stdout.write(stats.toString({
28-
colors: true,
29-
modules: false,
30-
children: false,
31-
chunks: false,
32-
chunkModules: false
33-
}) + '\n\n')
18+
webpack(webpackConfig, function (err, stats) {
19+
spinner.stop()
20+
if (err) throw err
21+
process.stdout.write(stats.toString({
22+
colors: true,
23+
modules: false,
24+
children: false,
25+
chunks: false,
26+
chunkModules: false
27+
}) + '\n\n')
3428

35-
console.log(chalk.cyan(' Build complete.\n'))
36-
console.log(chalk.yellow(
37-
' Tip: built files are meant to be served over an HTTP server.\n' +
38-
' Opening index.html over file:// won\'t work.\n'
39-
))
29+
console.log(chalk.cyan(' Build complete.\n'))
30+
console.log(chalk.yellow(
31+
' Tip: built files are meant to be served over an HTTP server.\n' +
32+
' Opening index.html over file:// won\'t work.\n'
33+
))
34+
})
4035
})

src/VueJsAspNetCoreSample/build/utils.js

Lines changed: 29 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -11,41 +11,48 @@ exports.assetsPath = function (_path) {
1111

1212
exports.cssLoaders = function (options) {
1313
options = options || {}
14+
15+
var cssLoader = {
16+
loader: 'css-loader',
17+
options: {
18+
minimize: process.env.NODE_ENV === 'production',
19+
sourceMap: options.sourceMap
20+
}
21+
}
22+
1423
// generate loader string to be used with extract text plugin
15-
function generateLoaders (loaders) {
16-
var sourceLoader = loaders.map(function (loader) {
17-
var extraParamChar
18-
if (/\?/.test(loader)) {
19-
loader = loader.replace(/\?/, '-loader?')
20-
extraParamChar = '&'
21-
} else {
22-
loader = loader + '-loader'
23-
extraParamChar = '?'
24-
}
25-
return loader + (options.sourceMap ? extraParamChar + 'sourceMap' : '')
26-
}).join('!')
24+
function generateLoaders (loader, loaderOptions) {
25+
var loaders = [cssLoader]
26+
if (loader) {
27+
loaders.push({
28+
loader: loader + '-loader',
29+
options: Object.assign({}, loaderOptions, {
30+
sourceMap: options.sourceMap
31+
})
32+
})
33+
}
2734

2835
// Extract CSS when that option is specified
2936
// (which is the case during production build)
3037
if (options.extract) {
3138
return ExtractTextPlugin.extract({
32-
use: sourceLoader,
39+
use: loaders,
3340
fallback: 'vue-style-loader'
3441
})
3542
} else {
36-
return ['vue-style-loader', sourceLoader].join('!')
43+
return ['vue-style-loader'].concat(loaders)
3744
}
3845
}
3946

4047
// http://vuejs.github.io/vue-loader/en/configurations/extract-css.html
4148
return {
42-
css: generateLoaders(['css']),
43-
postcss: generateLoaders(['css']),
44-
less: generateLoaders(['css', 'less']),
45-
sass: generateLoaders(['css', 'sass?indentedSyntax']),
46-
scss: generateLoaders(['css', 'sass']),
47-
stylus: generateLoaders(['css', 'stylus']),
48-
styl: generateLoaders(['css', 'stylus'])
49+
css: generateLoaders(),
50+
postcss: generateLoaders(),
51+
less: generateLoaders('less'),
52+
sass: generateLoaders('sass', { indentedSyntax: true }),
53+
scss: generateLoaders('sass'),
54+
stylus: generateLoaders('stylus'),
55+
styl: generateLoaders('stylus')
4956
}
5057
}
5158

@@ -57,7 +64,7 @@ exports.styleLoaders = function (options) {
5764
var loader = loaders[extension]
5865
output.push({
5966
test: new RegExp('\\.' + extension + '$'),
60-
loader: loader
67+
use: loader
6168
})
6269
}
6370
return output

src/VueJsAspNetCoreSample/build/vue-loader.conf.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,5 @@ module.exports = {
88
? config.build.productionSourceMap
99
: config.dev.cssSourceMap,
1010
extract: isProduction
11-
}),
12-
postcss: [
13-
require('autoprefixer')({
14-
browsers: ['last 2 versions']
15-
})
16-
]
11+
})
1712
}

src/VueJsAspNetCoreSample/build/webpack.base.conf.js

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,9 @@ module.exports = {
2020
},
2121
resolve: {
2222
extensions: ['.js', '.vue', '.json'],
23-
modules: [
24-
resolve('src'),
25-
resolve('node_modules')
26-
],
2723
alias: {
28-
'vue$': 'vue/dist/vue.common.js',
29-
'src': resolve('src'),
30-
'assets': resolve('src/assets'),
31-
'components': resolve('src/components')
24+
'vue$': 'vue/dist/vue.esm.js',
25+
'@': resolve('src'),
3226
}
3327
},
3428
module: {

src/VueJsAspNetCoreSample/build/webpack.prod.conf.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,11 @@ var webpack = require('webpack')
44
var config = require('../config')
55
var merge = require('webpack-merge')
66
var baseWebpackConfig = require('./webpack.base.conf')
7+
var CopyWebpackPlugin = require('copy-webpack-plugin')
78
var HtmlWebpackPlugin = require('html-webpack-plugin')
89
var ExtractTextPlugin = require('extract-text-webpack-plugin')
10+
var OptimizeCSSPlugin = require('optimize-css-assets-webpack-plugin')
11+
912
var env = process.env.NODE_ENV === 'testing'
1013
? require('../config/test.env')
1114
: config.build.env
@@ -38,6 +41,9 @@ var webpackConfig = merge(baseWebpackConfig, {
3841
new ExtractTextPlugin({
3942
filename: utils.assetsPath('css/[name].[contenthash].css')
4043
}),
44+
// Compress extracted CSS. We are using this plugin so that possible
45+
// duplicated CSS from different components can be deduped.
46+
new OptimizeCSSPlugin(),
4147
// generate dist index.html with correct asset hash for caching.
4248
// you can customize output by editing /index.html
4349
// see https://github.com/ampedandwired/html-webpack-plugin
@@ -76,7 +82,15 @@ var webpackConfig = merge(baseWebpackConfig, {
7682
new webpack.optimize.CommonsChunkPlugin({
7783
name: 'manifest',
7884
chunks: ['vendor']
79-
})
85+
}),
86+
// copy custom static assets
87+
new CopyWebpackPlugin([
88+
{
89+
from: path.resolve(__dirname, '../static'),
90+
to: config.build.assetsSubDirectory,
91+
ignore: ['.*']
92+
}
93+
])
8094
]
8195
})
8296

src/VueJsAspNetCoreSample/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<html>
33
<head>
44
<meta charset="utf-8">
5-
<title>Vue.js on ASP.NET Core Sample</title>
5+
<title>vuejs-sample</title>
66
</head>
77
<body>
88
<div id="app"></div>

0 commit comments

Comments
 (0)