Skip to content

Commit

Permalink
Add npm build script
Browse files Browse the repository at this point in the history
  • Loading branch information
tkw1536 committed Feb 9, 2019
1 parent 7ecee3d commit 280223d
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 40 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
node_modules
dist/
dist/
lib/
19 changes: 11 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,31 +1,34 @@
{
"name": "tgview",
"private": true,
"version": "0.0.1",
"main": "./src/index.ts",
"main": "./lib/index.js",
"types": "./lib/index.d.ts",
"license": "MIT",
"scripts": {
"start": "webpack-serve",
"build": "webpack --mode production",
"build": "tsc",
"install": "tsc",
"clean": "rm -rf lib/ dist/",
"lint": "tslint -p tsconfig.json"
},
"devDependencies": {
"@types/jquery": "^3.3.29",
"@types/jqueryui": "^1.12.7",
"@types/jstree": "^3.3.37",
"@types/vis": "^4.21.10",
"css-loader": "^2.1.0",
"html-webpack-plugin": "^3.2.0",
"source-map-loader": "^0.2.4",
"style-loader": "^0.23.1",
"ts-loader": "^5.3.3",
"tslint": "^5.12.1",
"typescript": "^3.3.1",
"url-loader": "^1.1.2",
"webpack": "^4.29.1",
"webpack-cli": "^3.2.3",
"webpack-serve": "^2.0.3"
},
"dependencies": {
"@types/jquery": "^3.3.29",
"@types/jqueryui": "^1.12.7",
"@types/jstree": "^3.3.37",
"@types/vis": "^4.21.10",
"typescript": "^3.3.1",
"jquery": "^3.3.1",
"jqueryui": "^1.11.1",
"jstree": "^3.3.7",
Expand Down
6 changes: 3 additions & 3 deletions entry.ts → src/demo/index.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
/**
* @file
*
* The main entry point for the TGView standalone html file
* The main entry point for the TGView demo
*/

import TGView from './src';
import TGView from '..';

// Load all of the required CSS
import './src/css/styles.css';
import '../css/styles.css';
// <link href="deps/fontawesome/css/font-awesome.min.css" rel="stylesheet" />
import 'vis/dist/vis.min.css';
// <link href="deps/jqueryui/jquery-ui.min.css" rel="stylesheet" type="text/css">
Expand Down
11 changes: 6 additions & 5 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
"target": "es6", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017','ES2018' or 'ESNEXT'. */
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
// "lib": [], /* Specify library files to be included in the compilation. */
"allowJs": true, /* Allow javascript files to be compiled. */
"checkJs": true, /* Report errors in .js files. */
"allowJs": false, /* Allow javascript files to be compiled. */
"checkJs": false, /* Report errors in .js files. */
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
// "declaration": true, /* Generates corresponding '.d.ts' file. */
"declaration": true, /* Generates corresponding '.d.ts' file. */
"sourceMap": true, /* Generates corresponding '.map' file. */
// "outFile": "./", /* Concatenate and emit output to single file. */
// "outDir": "./", /* Redirect output structure to the directory. */
"outDir": "lib/", /* Redirect output structure to the directory. */
// "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
// "removeComments": true, /* Do not emit comments to output. */
// "noEmit": true, /* Do not emit outputs. */
Expand Down Expand Up @@ -57,7 +57,8 @@
"exclude": [
"webpack.config.js",
"node_modules",
"src/demo",
"dist",
"deps"
"lib"
]
}
2 changes: 1 addition & 1 deletion tslint.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"defaultSeverity": "error",
"defaultSeverity": "warn",
"jsRules": {},
"rules": {
"quotemark": [true, "single"]
Expand Down
51 changes: 29 additions & 22 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,44 +1,51 @@
const path = require('path');
const HTMLPlugin = require('html-webpack-plugin');
/**
* @file
*
* This file contains configuration to run the demo locally.
*/
const path = require("path");
const HTMLPlugin = require("html-webpack-plugin");

module.exports = {
entry: './entry.ts',
mode: 'development',
devtool: 'inline-source-map',
entry: "./src/demo",
mode: "development",
devtool: "inline-source-map",
module: {
rules: [
// source maps from typescript work
{ test: /\.js$/, loader: 'source-map-loader', enforce: 'pre' },
{ test: /\.js$/, loader: "source-map-loader", enforce: "pre" },

// load typescript outside of node_modules
{
test: /\.tsx?$/,
use: 'ts-loader',
test: /\.ts$/,
use: "ts-loader",
exclude: /node_modules/
},
// load stylesheets -- only needed for development
{
test: /\.css$/, loader: ['style-loader', 'css-loader']
},
test: /\.css$/,
loader: ["style-loader", "css-loader"]
},

// load png images -- only needed for development
// load png images -- only needed for development
{
test: /\.(png|jpg|gif)$/,
loader: 'url-loader'
loader: "url-loader"
}
]
},
resolve: {
extensions: [ '.tsx', '.ts', '.js' ]
extensions: [".ts", ".js"]
},
output: {
// library: 'tgview',
// libraryTarget: 'umd',
filename: 'bundle.js',
path: path.resolve(__dirname, 'dist'),
devtoolModuleFilenameTemplate: '[absolute-resource-path]'
filename: '[name].bundle.js',
path: path.resolve(__dirname, "dist"),
devtoolModuleFilenameTemplate: "[absolute-resource-path]"
},
optimization: {
splitChunks: {
chunks: "all"
}
},
plugins: [
new HTMLPlugin()
]
plugins: [new HTMLPlugin()]
};

0 comments on commit 280223d

Please sign in to comment.