diff --git a/template/README.md b/template/README.md index 832606a..e462fe3 100644 --- a/template/README.md +++ b/template/README.md @@ -4,8 +4,17 @@ # Usage +```js +import Component from '{{name}}' + +Vue.component('{{name}}', Component); +``` + <{{name}} text="Hello World!"> +PS: You can also build to UMD with `npm run build:umd`, the component will be +available in the window['{{name}}'] variable. + ## Installation ### Using yarn diff --git a/template/build.config.js b/template/build.config.js deleted file mode 100644 index 0a5b523..0000000 --- a/template/build.config.js +++ /dev/null @@ -1,13 +0,0 @@ -const webpack = require.main.require('webpack') -const {name, version} = require('./package.json') - -module.exports = { - webpack: { - devtool: false, // disable source-map - plugins: [ - new webpack.DefinePlugin({ - 'proccess.env.VERSION': JSON.stringify(version) // adds MyComponent.version - }) - ] - } -} diff --git a/template/package.json b/template/package.json index 1647e11..56f0019 100644 --- a/template/package.json +++ b/template/package.json @@ -3,11 +3,12 @@ "version": "0.0.1", "description": "{{ description }}", "author": "{{ author }}", - "main": "dist/index.js", + "main": "dist/{{name}}.min.js", "license": "MIT", "scripts": { "lint": "eslint src", - "build": "vue build ./src/index.js --config ./build.config.js --dist ./dist/ --prod --lib", + "build": "poi build --format cjs", + "build:umd": "poi build --format umd", "build:doc": "vue-styleguidist build", "serve": "vue-styleguidist server" }, @@ -25,7 +26,8 @@ "babel-preset-es2015": "^6.24.1", "eslint": "^3.17.1", "eslint-plugin-vue": "beta", - "vue-cli": "^2.8.2", + "node-glob": "^1.2.0", + "poi": "^9.3.10", "vue-styleguidist": "^1.2.5", "vue-webpack-loaders": "^1.0.6", "webpack": "^3.1.0" diff --git a/template/poi.config.js b/template/poi.config.js new file mode 100644 index 0000000..da7012d --- /dev/null +++ b/template/poi.config.js @@ -0,0 +1,11 @@ +const glob = require('glob').sync; +const {name} = require('./package.json'); + +module.exports = { + entry: glob('./src/**/*.vue'), + filename: { + js: name + '.min.js', + }, + sourceMap: false, + html: false +}; diff --git a/template/src/index.js b/template/src/index.js deleted file mode 100644 index 3f357d4..0000000 --- a/template/src/index.js +++ /dev/null @@ -1,11 +0,0 @@ -import Component from './{{name}}/{{name}}.vue'; - -Component.install = Vue => Vue.component(Component.name, Component); -Component.version = process.env.VERSION; - -// Install by default if using the script tag -if (typeof window !== 'undefined' && window.Vue) { - window.Vue.use(Component) -} - -export default Component; diff --git a/template/styleguide.config.js b/template/styleguide.config.js index 4daec5f..730e2b7 100644 --- a/template/styleguide.config.js +++ b/template/styleguide.config.js @@ -9,7 +9,7 @@ module.exports = { /* The component itself */ name: '{{ name }}', content: 'docs/Introduction.md', - components: 'src/**/{{ name }}.vue', + components: 'src/**/*.vue', // ignore: ['src/ignored-component/ignored-component.vue'], sections: [ /* One item for each demo or example of the component */