Paravieweb(一)建立简单的Paraviewweb项目

系统环境:
ubuntu:18.04_64;
node:8.11.4;

建立简单的Paraviewweb项目

Paraviewweb项目是基于node.js的web应用

一、创建一个node.js项目

mkdir PvwWebProject
cd PvwWebProject
npm init

二、安装需要的依赖包

mkdir MyWebProject
 cd MyWebProject
 npm init
 npm install paraviewweb  --save
 npm install kw-web-suite --save-dev
 npm install normalize.css --save-dev
 npm install monologue.js --save-dev

三、新建webpack.config.js文件

const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');

const rules = require('./node_modules/paraviewweb/config/webpack.loaders.js');
const plugins = [
  new HtmlWebpackPlugin({
    inject: 'body',
  }),
];

const entry = path.join(__dirname, './src/index.js');
const outputPath = path.join(__dirname, './dist');
const styles = path.resolve('./node_modules/paraviewweb/style');

module.exports = {
  plugins,
  entry,
  output: {
    path: outputPath,
    filename: 'MyWebApp.js',
    libraryTarget: 'umd',
  },
  module: {
    rules: [
     { test: entry, loader: "expose-loader?MyWebApp" },
    ].concat(rules),
  },
  resolve: {
    alias: {
      PVWStyle: styles,
    },
  },
  devServer: {
    contentBase: './dist/',
    port: 9999,
    host:localhost
  },
};

四、新建index.js,在src文件夹下

import 'normalize.css';

import CompositeComponent from 'paraviewweb/src/Component/Native/Composite';
import BGColorComponent from 'paraviewweb/src/Component/Native/BackgroundColor';

const container = document.createElement('div');
document.body.appendChild(container);

container.style.position = 'relative';
container.style.width = '100%';
container.style.height = '600px';

const composite = new CompositeComponent();
const green = new BGColorComponent('green');
const red = new BGColorComponent('red');
const blue = new BGColorComponent('blue');
const pink = new BGColorComponent('pink');

composite.addViewport(green);
composite.addViewport(red);
composite.addViewport(blue);
composite.addViewport(pink);

composite.setContainer(container);

五、启动项目

npm run build 
npm start

这里写图片描述

  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 5
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值