Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added simple webpack example and renamed existing webpack example #869

Merged
merged 1 commit into from
Jan 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions examples/webpack-cross-origin/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Webpack Example

An example of consuming perspective through webpack, via `webpack-dev-server`,
hosted cross origin.
31 changes: 31 additions & 0 deletions examples/webpack-cross-origin/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"name": "webpack-cross-origin",
"private": true,
"version": "0.4.0",
"description": "An example of using the Perspective Webpack plugin to build a JS file with Webpack.",
"scripts": {
"start": "npm-run-all -l -p webpack-watch host:app host:bundles",
"host:app": "http-server ./dist/public -p 5150 -c-1",
"host:bundles": "http-server ./dist -p 8080 -c-1 --cors",
"webpack-watch": "webpack --watch"
},
"keywords": [],
"license": "Apache-2.0",
"dependencies": {
"@finos/perspective": "^0.4.0",
"@finos/perspective-viewer": "^0.4.0",
"@finos/perspective-viewer-d3fc": "^0.4.0",
"@finos/perspective-viewer-hypergrid": "^0.4.0"
},
"devDependencies": {
"@finos/perspective-webpack-plugin": "^0.4.0",
"css-loader": "^0.28.7",
"html-webpack-plugin": "^3.2.0",
"http-server": "^0.11.1",
"less-loader": "^4.0.5",
"npm-run-all": "^4.1.3",
"style-loader": "^0.18.2",
"webpack": "^4.41.2",
"webpack-dev-server": "3.9.0"
}
}
17 changes: 17 additions & 0 deletions examples/webpack-cross-origin/src/index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@

/******************************************************************************
*
* Copyright (c) 2017, the Perspective Authors.
*
* This file is part of the Perspective library, distributed under the terms of
* the Apache License 2.0. The full license can be found in the LICENSE file.
*
*/

perspective-viewer {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
}
17 changes: 17 additions & 0 deletions examples/webpack-cross-origin/src/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!--

Copyright (c) 2017, the Perspective Authors.

This file is part of the Perspective library, distributed under the terms of
the Apache License 2.0. The full license can be found in the LICENSE file.
-->

<html>
<head>
<meta charset="UTF-8">
<title>Perspective Webpack Example (Cross-Origin)</title>
</head>
<body>
<perspective-viewer></perspective-viewer>
</body>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
*/

import perspective from "@finos/perspective";
import "./index.less";
import "./index.css";
import "@finos/perspective-viewer";
import "@finos/perspective-viewer-hypergrid";
import "@finos/perspective-viewer-d3fc";
Expand Down
56 changes: 56 additions & 0 deletions examples/webpack-cross-origin/webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/******************************************************************************
*
* Copyright (c) 2017, the Perspective Authors.
*
* This file is part of the Perspective library, distributed under the terms of
* the Apache License 2.0. The full license can be found in the LICENSE file.
*
*/

const HtmlWebPackPlugin = require("html-webpack-plugin");
const PerspectivePlugin = require("@finos/perspective-webpack-plugin");

module.exports = {
context: __dirname,
entry: "./src/index.js",
mode: "development",
output: {
filename: "public/bundle.js",
publicPath: "http://localhost:8080/"
},
plugins: [
new HtmlWebPackPlugin({
title: "Perspective Webpack Cross-Origin Example",
template: "./src/index.html",
filename: "public/index.html",
inject: "head"
}),
new PerspectivePlugin({
wasmLoaderOptions: {
name: "[hash].wasm"
},
workerLoaderOptions: {
name: "[hash].worker.[ext]"
}
})
],
module: {
rules: [
{
test: /\.css$/,
exclude: [/packages/, /node_modules/],
use: [{loader: "style-loader"}, {loader: "css-loader"}]
}
]
},
devtool: "source-map",
devServer: {
historyApiFallback: true,
watchOptions: {aggregateTimeout: 300, poll: 1000},
headers: {
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Methods": "GET, POST, PUT, DELETE, PATCH, OPTIONS",
"Access-Control-Allow-Headers": "X-Requested-With, content-type, Authorization"
}
}
};
1 change: 0 additions & 1 deletion examples/webpack/.gitignore

This file was deleted.

3 changes: 1 addition & 2 deletions examples/webpack/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# Webpack Example

An exmple of consuming perspective through webpack, via `webpack-dev-server`,
hosted cross origin.
Simple webpack example using `perspective-viewer` and plugins.
4 changes: 0 additions & 4 deletions examples/webpack/index.less

This file was deleted.

9 changes: 0 additions & 9 deletions examples/webpack/output/public/index.html

This file was deleted.

19 changes: 8 additions & 11 deletions examples/webpack/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@
"name": "webpack",
"private": true,
"version": "0.4.0",
"description": "An example of using the Perspective Webpack plugin to build a JS file with Webpack.",
"description": "An example app built using `@finos/perspective-phosphor`.",
"scripts": {
"start": "npm-run-all -l -p webpack-watch host:app host:bundles",
"host:app": "http-server ./output/public -p 5150 -c-1",
"host:bundles": "http-server ./output -p 8080 -c-1 --cors",
"webpack-watch": "webpack --watch"
"start": "webpack-dev-server --open",
"webpack": "webpack --colour"
},
"keywords": [],
"license": "Apache-2.0",
Expand All @@ -20,12 +18,11 @@
"devDependencies": {
"@finos/perspective-webpack-plugin": "^0.4.0",
"css-loader": "^0.28.7",
"http-server": "^0.11.1",
"less-loader": "^4.0.5",
"npm-run-all": "^4.1.3",
"rimraf": "^2.5.2",
"file-loader": "^4.2.0",
"html-webpack-plugin": "^3.2.0",
"style-loader": "^0.18.2",
"webpack": "^4.41.2",
"webpack-dev-server": "3.9.0"
"webpack": "^4.31.0",
"webpack-cli": "^3.3.7",
"webpack-dev-server": "^3.8.0"
}
}
16 changes: 16 additions & 0 deletions examples/webpack/src/index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/******************************************************************************
*
* Copyright (c) 2018, the Perspective Authors.
*
* This file is part of the Perspective library, distributed under the terms of
* the Apache License 2.0. The full license can be found in the LICENSE file.
*
*/

perspective-viewer {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
}
37 changes: 37 additions & 0 deletions examples/webpack/src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/******************************************************************************
*
* Copyright (c) 2018, the Perspective Authors.
*
* This file is part of the Perspective library, distributed under the terms of
* the Apache License 2.0. The full license can be found in the LICENSE file.
*
*/

import perspective from "@finos/perspective";

import "@finos/perspective-viewer";
import "@finos/perspective-viewer-hypergrid";
import "@finos/perspective-viewer-d3fc";

import "@finos/perspective-viewer/dist/umd/material.css";

import "./index.css";

const worker = perspective.shared_worker();

// superstore.arrow located in examples/simple/ and it's configured by
// 'devServer' in 'webpack.config.js'
const req = fetch("./superstore.arrow");

window.addEventListener("load", async () => {
const viewer = document.createElement("perspective-viewer");
document.body.append(viewer);

const resp = await req;
const buffer = await resp.arrayBuffer();
const table = worker.table(buffer);

viewer.load(table);

window.viewer = viewer;
});
40 changes: 11 additions & 29 deletions examples/webpack/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,49 +8,31 @@
*/

const PerspectivePlugin = require("@finos/perspective-webpack-plugin");
const HtmlWebPackPlugin = require("html-webpack-plugin");
const path = require("path");

module.exports = {
context: __dirname,
entry: "./index.js",
mode: "development",
mode: process.env.NODE_ENV || "development",
entry: "./src/index.js",
output: {
filename: "public/bundle.js",
publicPath: "http://localhost:8080/",
path: path.resolve(__dirname, "./output")
filename: "index.js"
},
plugins: [
new PerspectivePlugin({
wasmLoaderOptions: {
name: "[hash].wasm"
},
workerLoaderOptions: {
name: "[hash].worker.[ext]"
}
})
new HtmlWebPackPlugin({
title: "Perspective Webpack Example"
}),
new PerspectivePlugin()
],
module: {
rules: [
{
test: /\.less$/,
exclude: [/packages/, /node_modules/],
use: [{loader: "style-loader"}, {loader: "css-loader"}, {loader: "less-loader"}]
},
{
test: /\.css$/,
exclude: [/packages/, /node_modules/],
use: [{loader: "style-loader"}, {loader: "css-loader"}]
}
]
},
devtool: "source-map",
devServer: {
historyApiFallback: true,
watchOptions: {aggregateTimeout: 300, poll: 1000},
headers: {
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Methods": "GET, POST, PUT, DELETE, PATCH, OPTIONS",
"Access-Control-Allow-Headers": "X-Requested-With, content-type, Authorization"
}
}
contentBase: [path.join(__dirname, "dist"), path.join(__dirname, "../simple")]
},
devtool: "source-map"
};