diff --git a/config/karma.conf.js b/config/karma.conf.js index 0e1709a..94f32a6 100644 --- a/config/karma.conf.js +++ b/config/karma.conf.js @@ -35,6 +35,7 @@ module.exports = function (config) { exclude: /node_modules/, loader: 'babel', query: { + presets: ['es2015'], plugins: ['babel-plugin-espower'] } }], diff --git a/config/webpack.conf.js b/config/webpack.conf.js index 197eaa0..d3bae62 100644 --- a/config/webpack.conf.js +++ b/config/webpack.conf.js @@ -3,13 +3,25 @@ var webpack = require('webpack') var banner = require('./banner') module.exports = { - entry: './lib/index.js', + entry: './src/index', output: { path: './dist', filename: pack.name + '.js', library: pack.name, libraryTarget: 'umd' }, + module: { + loaders: [{ + test: /\.js$/, + loader: 'babel', + query: { + presets: ['es2015'], + plugins: [ + ['transform-es2015-modules-commonjs', { loose: true }] + ] + } + }] + }, plugins: [ new webpack.BannerPlugin(banner) ] diff --git a/config/webpack.min.conf.js b/config/webpack.min.conf.js index ee87594..b526654 100644 --- a/config/webpack.min.conf.js +++ b/config/webpack.min.conf.js @@ -3,13 +3,25 @@ var webpack = require('webpack') var banner = require('./banner') module.exports = { - entry: './lib/index.js', + entry: './src/index', output: { path: './dist', filename: pack.name + '.min.js', library: pack.name, libraryTarget: 'umd' }, + module: { + loaders: [{ + test: /\.js$/, + loader: 'babel', + query: { + presets: ['es2015'], + plugins: [ + ['transform-es2015-modules-commonjs', { loose: true }] + ] + } + }] + }, plugins: [ new webpack.BannerPlugin(banner), new webpack.optimize.UglifyJsPlugin({ diff --git a/dist/vue-plugin-boilerplate.js b/dist/vue-plugin-boilerplate.js new file mode 100644 index 0000000..0491d38 --- /dev/null +++ b/dist/vue-plugin-boilerplate.js @@ -0,0 +1,77 @@ +/*! + * vue-plugin-boilerplate v1.0.0 + * (c) 2015 kazuya kawaguchi + * Released under the MIT License. + */ +(function webpackUniversalModuleDefinition(root, factory) { + if(typeof exports === 'object' && typeof module === 'object') + module.exports = factory(); + else if(typeof define === 'function' && define.amd) + define([], factory); + else if(typeof exports === 'object') + exports["vue-plugin-boilerplate"] = factory(); + else + root["vue-plugin-boilerplate"] = factory(); +})(this, function() { +return /******/ (function(modules) { // webpackBootstrap +/******/ // The module cache +/******/ var installedModules = {}; + +/******/ // The require function +/******/ function __webpack_require__(moduleId) { + +/******/ // Check if module is in cache +/******/ if(installedModules[moduleId]) +/******/ return installedModules[moduleId].exports; + +/******/ // Create a new module (and put it into the cache) +/******/ var module = installedModules[moduleId] = { +/******/ exports: {}, +/******/ id: moduleId, +/******/ loaded: false +/******/ }; + +/******/ // Execute the module function +/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); + +/******/ // Flag the module as loaded +/******/ module.loaded = true; + +/******/ // Return the exports of the module +/******/ return module.exports; +/******/ } + + +/******/ // expose the modules object (__webpack_modules__) +/******/ __webpack_require__.m = modules; + +/******/ // expose the module cache +/******/ __webpack_require__.c = installedModules; + +/******/ // __webpack_public_path__ +/******/ __webpack_require__.p = ""; + +/******/ // Load entry module and return exports +/******/ return __webpack_require__(0); +/******/ }) +/************************************************************************/ +/******/ ([ +/* 0 */ +/***/ function(module, exports) { + + "use strict"; + + exports.__esModule = true; + + exports.default = function (Vue) { + var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; + + Vue.prototype.$add = function (a, b) { + return a + b; + }; + }; + +/***/ } +/******/ ]) +}); +; \ No newline at end of file diff --git a/dist/vue-plugin-boilerplate.min.js b/dist/vue-plugin-boilerplate.min.js new file mode 100644 index 0000000..fafa069 --- /dev/null +++ b/dist/vue-plugin-boilerplate.min.js @@ -0,0 +1,6 @@ +/*! + * vue-plugin-boilerplate v1.0.0 + * (c) 2015 kazuya kawaguchi + * Released under the MIT License. + */ +!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports["vue-plugin-boilerplate"]=t():e["vue-plugin-boilerplate"]=t()}(this,function(){return function(e){function t(n){if(o[n])return o[n].exports;var r=o[n]={exports:{},id:n,loaded:!1};return e[n].call(r.exports,r,r.exports,t),r.loaded=!0,r.exports}var o={};return t.m=e,t.c=o,t.p="",t(0)}([function(e,t){"use strict";t.__esModule=!0,t["default"]=function(e){arguments.length<=1||void 0===arguments[1]?{}:arguments[1];e.prototype.$add=function(e,t){return e+t}}}])}); \ No newline at end of file diff --git a/package.json b/package.json index 0d47126..9b42cb9 100644 --- a/package.json +++ b/package.json @@ -10,13 +10,14 @@ "url": "/~https://github.com/kazupon/vue-plugin-boilerplate/issues" }, "devDependencies": { - "babel": "^5.8.23", - "babel-core": "^5.8.23", - "babel-loader": "^5.3.2", - "babel-plugin-espower": "^1.0.0", - "eslint": "^1.3.1", + "babel-core": "^6.2.1", + "babel-loader": "^6.2.0", + "babel-plugin-espower": "^2.0.0", + "babel-plugin-transform-es2015-modules-commonjs": "^6.3.13", + "babel-preset-es2015": "^6.1.18", + "eslint": "^1.10.2", "istanbul-instrumenter-loader": "^0.1.3", - "json-loader": "^0.5.2", + "json-loader": "^0.5.4", "karma": "^0.13.9", "karma-coverage": "^0.5.2", "karma-mocha": "^0.2.0", @@ -24,12 +25,17 @@ "karma-phantomjs-launcher": "^0.2.1", "karma-sourcemap-loader": "^0.3.5", "karma-webpack": "^1.7.0", - "mocha": "^2.3.1", + "mocha": "^2.3.4", "phantomjs": "^1.9.18", - "power-assert": "^1.0.0", - "vue": "^0.12.13", - "webpack": "^1.12.1" + "power-assert": "^1.2.0", + "vue": "^1.0.10", + "webpack": "^1.12.9" }, + "files": [ + "dist/vue-plugin-boilerplate.js", + "dist/vue-plugin-boilerplate.min.js", + "src" + ], "homepage": "/~https://github.com/kazupon/vue-plugin-boilerplate#readme", "keywords": [ "boilerplate", @@ -39,16 +45,18 @@ ], "license": "MIT", "main": "dist/vue-plugin-boilerplate.js", + "private": true, "repository": { "type": "git", "url": "git+/~https://github.com/kazupon/vue-plugin-boilerplate.git" }, "scripts": { - "build": "babel src --out-dir lib --source-maps-inline", - "bundle": "webpack --config config/webpack.conf.js && webpack --config config/webpack.min.conf.js", - "clean": "rm -rf lib && rm -rf coverage && rm -rf dist", + "build": "webpack --config config/webpack.conf.js", + "clean": "rm -rf coverage && rm -rf dist", + "dist": "npm run build && npm run minify", "lint": "eslint src test config", + "minify": "webpack --config config/webpack.min.conf.js", "test": "karma start config/karma.conf.js", - "watch": "babel src --out-dir lib --watch --source-maps-inline" + "watch": "webpack --watch --config config/webpack.conf.js" } } diff --git a/test/index.js b/test/index.js index 3606e23..dc4c463 100644 --- a/test/index.js +++ b/test/index.js @@ -1,6 +1,6 @@ import assert from 'power-assert' import Vue from 'vue' -import plugin from '../src/index.js' +import plugin from '../src/index' describe('$add', () => { let vm