Skip to content

Commit 160a54b

Browse files
committed
adjust build setup
1 parent 08dd24f commit 160a54b

12 files changed

+55
-81
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
dist/vue.js.map
12
dist/vue.min.js.gz
23
test/unit/specs.js
4+
test/unit/specs.js.map
35
explorations
46
node_modules
57
.DS_Store

grunt/tasks/build.js build/grunt-tasks/build.js

+26-4
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,15 @@ module.exports = function (grunt) {
88
var done = this.async()
99
var fs = require('fs')
1010
var zlib = require('zlib')
11-
var build = require('../shared-build')
11+
var webpack = require('webpack')
1212
var uglifyjs = require('uglify-js')
13+
14+
var banner =
15+
'/**\n' +
16+
' * Vue.js v' + grunt.config.get('version') + '\n' +
17+
' * (c) ' + new Date().getFullYear() + ' Evan You\n' +
18+
' * Released under the MIT License.\n' +
19+
' */\n'
1320

1421
// update component.json first
1522
var jsRE = /\.js$/
@@ -22,9 +29,24 @@ module.exports = function (grunt) {
2229
})
2330
grunt.file.write('component.json', JSON.stringify(component, null, 2))
2431

25-
// then build
26-
build(grunt, function (err) {
32+
// build
33+
webpack({
34+
entry: './src/vue',
35+
output: {
36+
path: './dist',
37+
filename: 'vue.js',
38+
library: 'Vue',
39+
libraryTarget: 'umd'
40+
},
41+
plugins: [
42+
new webpack.BannerPlugin(banner, { raw: true })
43+
]
44+
}, function (err, stats) {
2745
if (err) return done(err)
46+
minify()
47+
})
48+
49+
function minify () {
2850
var js = fs.readFileSync('dist/vue.js', 'utf-8')
2951
report('dist/vue.js', js)
3052
// uglify
@@ -50,7 +72,7 @@ module.exports = function (grunt) {
5072
write('dist/vue.min.js.gz', buf)
5173
done(err)
5274
})
53-
})
75+
}
5476

5577
function write (path, file) {
5678
fs.writeFileSync(path, file)
File renamed without changes.
File renamed without changes.
File renamed without changes.

build/webpack-dev-config.js

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
module.exports = {
2+
entry: './src/vue',
3+
output: {
4+
path: './dist',
5+
filename: 'vue.js',
6+
library: 'Vue',
7+
libraryTarget: 'umd'
8+
},
9+
devtool: '#source-map'
10+
}

build/webpack-test-config.js

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
var glob = require('grunt/node_modules/glob')
2+
var specs = glob.sync('test/unit/specs/**/*.js').map(function (f) {
3+
return './' + f
4+
})
5+
6+
module.exports = {
7+
entry: specs,
8+
output: {
9+
path: './test/unit',
10+
filename: 'specs.js'
11+
},
12+
devtool: '#source-map'
13+
}

grunt/shared-build.js

-28
This file was deleted.

grunt/tasks/build-test.js

-21
This file was deleted.

grunt/tasks/dev.js

-9
This file was deleted.

gruntfile.js

+2-17
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
var sauceConfig = require('./grunt/sauce')
1+
var sauceConfig = require('./build/saucelabs-config')
22

33
module.exports = function (grunt) {
44

@@ -22,20 +22,6 @@ module.exports = function (grunt) {
2222
}
2323
},
2424

25-
watch: {
26-
options: {
27-
nospawn: true
28-
},
29-
dev: {
30-
files: ['src/**/*.js'],
31-
tasks: ['dev']
32-
},
33-
test: {
34-
files: ['src/**/*.js', 'test/unit/specs/**/*.js'],
35-
tasks: ['build-test']
36-
}
37-
},
38-
3925
karma: {
4026
options: {
4127
frameworks: ['jasmine', 'commonjs'],
@@ -94,12 +80,11 @@ module.exports = function (grunt) {
9480

9581
// load npm tasks
9682
grunt.loadNpmTasks('grunt-contrib-jshint')
97-
grunt.loadNpmTasks('grunt-contrib-watch')
9883
grunt.loadNpmTasks('grunt-karma')
9984
grunt.loadNpmTasks('grunt-karma-coveralls')
10085

10186
// load custom tasks
102-
grunt.file.recurse('grunt/tasks', function (path) {
87+
grunt.file.recurse('build/grunt-tasks', function (path) {
10388
require('./' + path)(grunt)
10489
})
10590

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@
1717
"bugs": "https://github.com/yyx990803/vue/issues",
1818
"homepage": "http://vuejs.org",
1919
"scripts": {
20-
"test": "grunt ci"
20+
"test": "grunt ci",
21+
"dev": "webpack --watch --config build/webpack-dev-config.js & webpack --watch --config build/webpack-test-config.js"
2122
},
2223
"devDependencies": {
2324
"grunt": "^0.4.5",
2425
"grunt-contrib-jshint": "^0.10.0",
25-
"grunt-contrib-watch": "^0.6.1",
2626
"grunt-karma": "^0.8.3",
2727
"grunt-karma-coveralls": "^2.5.3",
2828
"jshint-stylish": "^0.3.0",

0 commit comments

Comments
 (0)