hypejunction / vue-boot
Vue bootstrap for Elgg
Installs: 3
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 2
Forks: 0
Open Issues: 24
Type:elgg-plugin
Requires
- php: >=7.0
- composer/installers: ~1.0
- dev-master
- 1.0.0
- dev-dependabot/npm_and_yarn/json5-1.0.2
- dev-dependabot/npm_and_yarn/express-4.18.2
- dev-dependabot/npm_and_yarn/qs-6.5.3
- dev-dependabot/npm_and_yarn/decode-uri-component-0.2.2
- dev-dependabot/npm_and_yarn/loader-utils-and-webpack-cli-1.4.2
- dev-dependabot/npm_and_yarn/eventsource-1.1.1
- dev-dependabot/npm_and_yarn/grunt-1.5.3
- dev-dependabot/npm_and_yarn/url-parse-1.5.10
- dev-dependabot/npm_and_yarn/follow-redirects-1.14.8
- dev-dependabot/npm_and_yarn/ajv-6.12.6
- dev-dependabot/npm_and_yarn/path-parse-1.0.7
- dev-dependabot/npm_and_yarn/ws-6.2.2
- dev-dependabot/npm_and_yarn/dns-packet-1.3.4
- dev-dependabot/npm_and_yarn/browserslist-4.16.6
- dev-dependabot/npm_and_yarn/hosted-git-info-2.8.9
- dev-dependabot/npm_and_yarn/lodash-4.17.21
- dev-dependabot/npm_and_yarn/handlebars-4.7.7
- dev-dependabot/npm_and_yarn/underscore-1.12.1
- dev-dependabot/npm_and_yarn/ssri-6.0.2
- dev-dependabot/npm_and_yarn/y18n-4.0.1
- dev-dependabot/npm_and_yarn/elliptic-6.5.4
- dev-dependabot/npm_and_yarn/http-proxy-1.18.1
- dev-dependabot/npm_and_yarn/websocket-extensions-0.1.4
- dev-dependabot/npm_and_yarn/acorn-6.4.1
This package is auto-updated.
Last update: 2024-11-04 16:12:09 UTC
README
Provides a generic bootstrap for using Vue components inside Elgg.
Setup
Inside your plugin create:
package.json
{ "private": true, "scripts": { "build": "npm run production && rm ./views/default/mix-manifest.json && php ../../elgg-cli flush", "production": "npm run components:parse && cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --no-progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js", "components:parse": "node node_modules/@hypejunction/vue-scanner/cli/scan.js" }, "dependencies": { "cross-env": "^5.2.0", "global": "^4.4.0", "laravel-mix": "^4.1.2", "lodash.camelcase": "^4.3.0", "vue": "^2.6.10", "vue-template-compiler": "^2.6.10" }, "devDependencies": { "@babel/plugin-syntax-dynamic-import": "^7.2.0", "@hypejunction/vue-scanner": "^1.1.3" }, "vue-scanner": { "src": { "components": { "dirs": [ "./src/PLUGIN_NAME/components/" ], "async": false } }, "target": { "js": "./src/PLUGIN_NAME/components.js", "json": "./src/PLUGIN_NAME/components.json" }, "chunks": true, "requestChunks": true, "chunkPrefix": "PLUGIN_NAME/" } }
webpack.mix.js
let mix = require('laravel-mix'); mix.setPublicPath('views/default/') .setResourceRoot('views/default/') .js('src/PLUGIN_NAME/init.js', 'views/default/PLUGIN_NAME/init.js'); mix.webpackConfig({ externals: { elgg: 'elgg', vue: 'vue', }, optimization: { splitChunks: false, }, output: { libraryTarget: 'umd', publicPath: `/mod/PLUGIN_NAME/views/default/`, } });
src/PLUGIN_NAME/init.js
Inside your init.js
you can use ES6 to import Vue, register your components, setup your Vue extensions etc.
import Vue from 'vue'; // Vue.component(); import './components';
The above setup makes it easier to work with components, using vue-scanner
, which will automatically register all the components for you. You will just need to import the components.js
in your init.js
.
Then run yarn build
- this will build your components into views/default
, so you can use them inside your templates.
You can then add these components into your plugin's views:
echo \hypeJunction\VueBoot\Vue::instance()->render('MyComponent', [ 'params' => $entity->getParams(), // list all props to pass to the component ], [ 'PLUGIN_NAME/init', // load the init script ]);