项目作者: ChristianBielak

项目描述 :
Vue Pagebuilder Component for Laravel and Vue SPA
高级语言: TypeScript
项目地址: git://github.com/ChristianBielak/vue-pagebuilder.git
创建时间: 2019-02-13T10:26:40Z
项目社区:https://github.com/ChristianBielak/vue-pagebuilder

开源协议:MIT License

下载







Vue Pagebuilder

Demo

Dashboard

Frontend Demo coming soon…

Notes

This package is still in development and is NOT yet intended for production use.


The README for customization will be coming soon.

Installtion

  1. npm install @chrisbielak/vue-pagebuilder
  2. or use yarn
  3. yarn add @chrisbielak/vue-pagebuilder

Set up TypeScript

The Pagebuilder was written in TypeScript, which will be installed automatically
with all required dependencies.

You can skip this step if you want to use the Pagebuilder within a TypeScript ready Vue.js SPA.

If you want to use it in a Laravel project you have to make the project TypeScript ready.

First of all you have to modify your webpack.mix.json.

  1. ...
  2. module:{
  3. rules:[
  4. {
  5. test: /\.tsx?$/,
  6. loader: "ts-loader",
  7. exclude: /node_modules/
  8. }
  9. ]
  10. },
  11. resolve: {
  12. extensions: ['*', '.js', '.jsx', '.vue', '.ts', '.tsx'],
  13. alias:{
  14. '@': path.resolve(__dirname, './resources/js')
  15. }
  16. },
  17. ...

Because of dynamic importing of the Pagebuilder elements it’s recommended to define a path for the chunk files.

A simple implementation can look like this:

  1. let chunkFilename = 'js/chunks/[name].js';
  2. mix.js('resources/js/app.js', 'public/js')
  3. .sass('resources/sass/app.scss', 'public/css');
  4. mix.webpackConfig({
  5. output: {
  6. publicPath: '/',
  7. chunkFilename: chunkFilename
  8. },
  9. module:{
  10. rules:[
  11. {
  12. test: /\.tsx?$/,
  13. loader: "ts-loader",
  14. exclude: /node_modules/
  15. }
  16. ]
  17. },
  18. resolve: {
  19. extensions: ['*', '.js', '.jsx', '.vue', '.ts', '.tsx'],
  20. alias:{
  21. '@': path.resolve(__dirname, './resources/js')
  22. }
  23. },
  24. });

The last step that needs to be done is to create the tsconfig.json file.

I use the default tsconfig.json which is created by the Vue cli.

  1. {
  2. "compilerOptions": {
  3. "target": "esnext",
  4. "module": "esnext",
  5. "strict": true,
  6. "jsx": "preserve",
  7. "importHelpers": true,
  8. "moduleResolution": "node",
  9. "experimentalDecorators": true,
  10. "esModuleInterop": true,
  11. "allowSyntheticDefaultImports": true,
  12. "strictPropertyInitialization": false,
  13. "sourceMap": true,
  14. "baseUrl": ".",
  15. "declaration": false,
  16. "types": [
  17. ],
  18. "paths": {
  19. "@/*": [
  20. "resources/js/*"
  21. ]
  22. },
  23. "lib": [
  24. "esnext",
  25. "dom",
  26. "dom.iterable",
  27. "scripthost"
  28. ]
  29. },
  30. "include": [
  31. "resources/**/*.ts",
  32. "resources/**/*.tsx",
  33. "resources/**/*.vue"
  34. ],
  35. "exclude": [
  36. "node_modules"
  37. ]
  38. }

How to use the Pagebuilder

First you have to register the component and register the Vuex store which has a default set up.

  1. import PagebuilderComponent from "./pagebuilder/components/PagebuilderComponent/PagebuilderComponent";
  2. import store from './pagebuilder/store/store'
  3. new Vue({
  4. el: '#app',
  5. components: {
  6. PagebuilderComponent,
  7. },
  8. store
  9. });

Now you can use the pagebuilder-component inside your project wherever it’s needed.

  1. <pagebuilder-component></pagebuilder-component>