Explorar el Código

adjust build setup

Evan You hace 11 años
padre
commit
160a54bd94

+ 2 - 0
.gitignore

@@ -1,5 +1,7 @@
+dist/vue.js.map
 dist/vue.min.js.gz
 dist/vue.min.js.gz
 test/unit/specs.js
 test/unit/specs.js
+test/unit/specs.js.map
 explorations
 explorations
 node_modules
 node_modules
 .DS_Store
 .DS_Store

+ 26 - 4
grunt/tasks/build.js → build/grunt-tasks/build.js

@@ -8,8 +8,15 @@ module.exports = function (grunt) {
     var done = this.async()
     var done = this.async()
     var fs = require('fs')
     var fs = require('fs')
     var zlib = require('zlib')
     var zlib = require('zlib')
-    var build = require('../shared-build')
+    var webpack = require('webpack')
     var uglifyjs = require('uglify-js')
     var uglifyjs = require('uglify-js')
+
+    var banner =
+        '/**\n' +
+        ' * Vue.js v' + grunt.config.get('version') + '\n' +
+        ' * (c) ' + new Date().getFullYear() + ' Evan You\n' +
+        ' * Released under the MIT License.\n' +
+        ' */\n'
     
     
     // update component.json first
     // update component.json first
     var jsRE = /\.js$/
     var jsRE = /\.js$/
@@ -22,9 +29,24 @@ module.exports = function (grunt) {
     })
     })
     grunt.file.write('component.json', JSON.stringify(component, null, 2))
     grunt.file.write('component.json', JSON.stringify(component, null, 2))
 
 
-    // then build
-    build(grunt, function (err) {
+    // build
+    webpack({
+      entry: './src/vue',
+      output: {
+        path: './dist',
+        filename: 'vue.js',
+        library: 'Vue',
+        libraryTarget: 'umd'
+      },
+      plugins: [
+        new webpack.BannerPlugin(banner, { raw: true })
+      ]
+    }, function (err, stats) {
       if (err) return done(err)
       if (err) return done(err)
+      minify()
+    })
+
+    function minify () {
       var js = fs.readFileSync('dist/vue.js', 'utf-8')
       var js = fs.readFileSync('dist/vue.js', 'utf-8')
       report('dist/vue.js', js)
       report('dist/vue.js', js)
       // uglify
       // uglify
@@ -50,7 +72,7 @@ module.exports = function (grunt) {
         write('dist/vue.min.js.gz', buf)
         write('dist/vue.min.js.gz', buf)
         done(err)
         done(err)
       })
       })
-    })
+    }
 
 
     function write (path, file) {
     function write (path, file) {
       fs.writeFileSync(path, file)
       fs.writeFileSync(path, file)

+ 0 - 0
grunt/tasks/casper.js → build/grunt-tasks/casper.js


+ 0 - 0
grunt/tasks/release.js → build/grunt-tasks/release.js


+ 0 - 0
grunt/sauce.js → build/saucelabs-config.js


+ 10 - 0
build/webpack-dev-config.js

@@ -0,0 +1,10 @@
+module.exports = {
+  entry: './src/vue',
+  output: {
+    path: './dist',
+    filename: 'vue.js',
+    library: 'Vue',
+    libraryTarget: 'umd'
+  },
+  devtool: '#source-map'
+}

+ 13 - 0
build/webpack-test-config.js

@@ -0,0 +1,13 @@
+var glob = require('grunt/node_modules/glob')
+var specs = glob.sync('test/unit/specs/**/*.js').map(function (f) {
+  return './' + f
+})
+
+module.exports = {
+  entry: specs,
+  output: {
+    path: './test/unit',
+    filename: 'specs.js'
+  },
+  devtool: '#source-map'
+}

+ 0 - 28
grunt/shared-build.js

@@ -1,28 +0,0 @@
-/**
- * Shared build function
- */
-
-module.exports = function (grunt, cb) {
-
-  var webpack = require('webpack')
-  var banner =
-    '/**\n' +
-    ' * Vue.js v' + grunt.config.get('version') + '\n' +
-    ' * (c) ' + new Date().getFullYear() + ' Evan You\n' +
-    ' * Released under the MIT License.\n' +
-    ' */\n'
-
-  webpack({
-    entry: './src/vue',
-    output: {
-      path: './dist',
-      filename: 'vue.js',
-      library: 'Vue',
-      libraryTarget: 'umd'
-    },
-    plugins: [
-      new webpack.BannerPlugin(banner, { raw: true })
-    ]
-  }, cb)
-
-}

+ 0 - 21
grunt/tasks/build-test.js

@@ -1,21 +0,0 @@
-/**
- * Build `test/unit/specs.js` which is used in
- * `test/unit/runner.html`
- */
-
-module.exports = function (grunt) {
-  grunt.registerTask('build-test', function () {
-    var webpack = require('webpack')
-    var files = grunt.file.expand(['test/unit/specs/**/*.js'])
-      .map(function (file) {
-        return './' + file
-      })
-    webpack({
-      entry: files,
-      output: {
-        path: './test/unit',
-        filename: 'specs.js'
-      }
-    }, this.async())
-  })
-}

+ 0 - 9
grunt/tasks/dev.js

@@ -1,9 +0,0 @@
-/**
- * Simple development build to be run with grunt watch.
- */
-
-module.exports = function (grunt) {
-  grunt.registerTask('dev', function () {
-    require('../shared-build')(grunt, this.async())
-  })
-}

+ 2 - 17
gruntfile.js

@@ -1,4 +1,4 @@
-var sauceConfig = require('./grunt/sauce')
+var sauceConfig = require('./build/saucelabs-config')
 
 
 module.exports = function (grunt) {
 module.exports = function (grunt) {
 
 
@@ -22,20 +22,6 @@ module.exports = function (grunt) {
       }
       }
     },
     },
 
 
-    watch: {
-      options: {
-        nospawn: true
-      },
-      dev: {
-        files: ['src/**/*.js'],
-        tasks: ['dev']
-      },
-      test: {
-        files: ['src/**/*.js', 'test/unit/specs/**/*.js'],
-        tasks: ['build-test']
-      }
-    },
-
     karma: {
     karma: {
       options: {
       options: {
         frameworks: ['jasmine', 'commonjs'],
         frameworks: ['jasmine', 'commonjs'],
@@ -94,12 +80,11 @@ module.exports = function (grunt) {
   
   
   // load npm tasks
   // load npm tasks
   grunt.loadNpmTasks('grunt-contrib-jshint')
   grunt.loadNpmTasks('grunt-contrib-jshint')
-  grunt.loadNpmTasks('grunt-contrib-watch')
   grunt.loadNpmTasks('grunt-karma')
   grunt.loadNpmTasks('grunt-karma')
   grunt.loadNpmTasks('grunt-karma-coveralls')
   grunt.loadNpmTasks('grunt-karma-coveralls')
 
 
   // load custom tasks
   // load custom tasks
-  grunt.file.recurse('grunt/tasks', function (path) {
+  grunt.file.recurse('build/grunt-tasks', function (path) {
     require('./' + path)(grunt)
     require('./' + path)(grunt)
   })
   })
 
 

+ 2 - 2
package.json

@@ -17,12 +17,12 @@
   "bugs": "https://github.com/yyx990803/vue/issues",
   "bugs": "https://github.com/yyx990803/vue/issues",
   "homepage": "http://vuejs.org",
   "homepage": "http://vuejs.org",
   "scripts": {
   "scripts": {
-    "test": "grunt ci"
+    "test": "grunt ci",
+    "dev": "webpack --watch --config build/webpack-dev-config.js & webpack --watch --config build/webpack-test-config.js"
   },
   },
   "devDependencies": {
   "devDependencies": {
     "grunt": "^0.4.5",
     "grunt": "^0.4.5",
     "grunt-contrib-jshint": "^0.10.0",
     "grunt-contrib-jshint": "^0.10.0",
-    "grunt-contrib-watch": "^0.6.1",
     "grunt-karma": "^0.8.3",
     "grunt-karma": "^0.8.3",
     "grunt-karma-coveralls": "^2.5.3",
     "grunt-karma-coveralls": "^2.5.3",
     "jshint-stylish": "^0.3.0",
     "jshint-stylish": "^0.3.0",