Skip to content

Commit 5128b19

Browse files
committed
Get plugin Use to work with installation mode
1 parent d747302 commit 5128b19

File tree

4 files changed

+85
-13
lines changed

4 files changed

+85
-13
lines changed

examples/src/main.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,15 @@
22
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
33
import Vue from 'vue'
44
import App from './App'
5+
import FloatThead from '../../dist/vue-floatthead.js'
56

67
Vue.config.productionTip = false
78

9+
Vue.use(FloatThead)
10+
811
/* eslint-disable no-new */
912
new Vue({
1013
el: '#app',
11-
template: '<App/>',
14+
template: '<div><App/></div>',
1215
components: { App }
1316
})

package.json

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@
44
"description": "Vue 2 component for jquery.floatThead",
55
"author": " <tm89lee@gmail.com>",
66
"private": false,
7-
"keywords":[
7+
"main": "dist/vue-floatthead.js",
8+
"module": "dist/vue-floatthead.js",
9+
"unpkg": "dist/vue-floatthead.js",
10+
"keywords": [
811
"vue",
912
"vuejs",
1013
"floatthead",
@@ -35,19 +38,22 @@
3538
"babel-core": "^6.22.1",
3639
"babel-eslint": "^7.1.1",
3740
"babel-loader": "^6.2.10",
41+
"babel-plugin-istanbul": "^3.1.2",
3842
"babel-plugin-transform-runtime": "^6.22.0",
3943
"babel-preset-env": "^1.2.1",
4044
"babel-preset-stage-2": "^6.22.0",
4145
"babel-register": "^6.22.0",
46+
"chai": "^3.5.0",
4247
"chalk": "^1.1.3",
4348
"connect-history-api-fallback": "^1.3.0",
4449
"copy-webpack-plugin": "^4.0.1",
50+
"cross-env": "^3.1.4",
4551
"css-loader": "^0.26.1",
4652
"eslint": "^3.14.1",
53+
"eslint-config-standard": "^6.2.1",
4754
"eslint-friendly-formatter": "^2.0.7",
4855
"eslint-loader": "^1.6.1",
4956
"eslint-plugin-html": "^2.0.0",
50-
"eslint-config-standard": "^6.2.1",
5157
"eslint-plugin-promise": "^3.4.0",
5258
"eslint-plugin-standard": "^2.0.1",
5359
"eventsource-polyfill": "^0.9.6",
@@ -58,8 +64,7 @@
5864
"function-bind": "^1.1.0",
5965
"html-webpack-plugin": "^2.28.0",
6066
"http-proxy-middleware": "^0.17.3",
61-
"webpack-bundle-analyzer": "^2.2.1",
62-
"cross-env": "^3.1.4",
67+
"inject-loader": "^2.0.1",
6368
"karma": "^1.4.1",
6469
"karma-coverage": "^1.1.1",
6570
"karma-mocha": "^1.3.0",
@@ -70,25 +75,24 @@
7075
"karma-webpack": "^2.0.2",
7176
"lolex": "^1.5.2",
7277
"mocha": "^3.2.0",
73-
"chai": "^3.5.0",
74-
"sinon": "^1.17.7",
75-
"sinon-chai": "^2.8.0",
76-
"inject-loader": "^2.0.1",
77-
"babel-plugin-istanbul": "^3.1.2",
78-
"phantomjs-prebuilt": "^2.1.14",
79-
"semver": "^5.3.0",
8078
"opn": "^4.0.2",
8179
"optimize-css-assets-webpack-plugin": "^1.3.0",
8280
"ora": "^1.1.0",
81+
"phantomjs-prebuilt": "^2.1.14",
8382
"rimraf": "^2.6.0",
83+
"semver": "^5.3.0",
84+
"sinon": "^1.17.7",
85+
"sinon-chai": "^2.8.0",
8486
"url-loader": "^0.5.7",
8587
"vue-loader": "^11.1.4",
8688
"vue-style-loader": "^2.0.0",
8789
"vue-template-compiler": "^2.2.4",
8890
"webpack": "^2.2.1",
91+
"webpack-bundle-analyzer": "^2.2.1",
8992
"webpack-dev-middleware": "^1.10.0",
9093
"webpack-hot-middleware": "^2.16.1",
91-
"webpack-merge": "^2.6.1"
94+
"webpack-merge": "^2.6.1",
95+
"webpack-node-externals": "^1.5.4"
9296
},
9397
"engines": {
9498
"node": ">= 4.0.0",

src/main.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import FloatThead from './components/FloatThead.vue'
2+
3+
function install(Vue, options) {
4+
Vue.component('FloatThead', FloatThead);
5+
}
6+
7+
export default install;

webpack.config.js

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
const path = require('path');
2+
const webpack = require('webpack');
3+
const nodeExternals = require('webpack-node-externals');
4+
5+
const config = module.exports = {
6+
plugins: []
7+
};
8+
9+
// Set context to root of project
10+
config.context = path.resolve(__dirname);
11+
12+
// Client entry
13+
config.entry = {
14+
"vue-floatThead": path.resolve(__dirname, 'src/main')
15+
};
16+
17+
// Basic output config
18+
config.output = {
19+
path: path.resolve(__dirname, 'dist'),
20+
filename: 'vue-floatthead.js',
21+
library: ["vue-floatThead"],
22+
libraryTarget: "umd",
23+
};
24+
25+
config.externals = [{
26+
'vue': {
27+
umd: 'Vue',
28+
global: 'Vue',
29+
root: 'Vue',
30+
commonjs2: 'vue',
31+
commonjs: 'vue',
32+
amd: 'vue'
33+
}
34+
}];
35+
// Resolver config
36+
config.resolve = {
37+
extensions: ['.js', '.vue'],
38+
enforceExtension: false
39+
};
40+
41+
config.resolveLoader = {
42+
modules: config.resolve.modules
43+
};
44+
45+
config.module = {
46+
loaders: [
47+
{
48+
test: /\.vue$/,
49+
loader: 'vue-loader'
50+
},
51+
{
52+
test: /\.js$/,
53+
loader: 'babel-loader',
54+
// important: exclude files in node_modules, otherwise it's going to be really slow!
55+
exclude: /node_modules|vendor/
56+
},
57+
]
58+
};

0 commit comments

Comments
 (0)