Skip to content
This repository was archived by the owner on Sep 24, 2020. It is now read-only.

NPM module configuration #31

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
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
7 changes: 7 additions & 0 deletions template/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# IntelliJ project files
.idea/
src/
config/
environment/
karma.*.js
webpack.*.js
21 changes: 21 additions & 0 deletions template/config/webpack.config.module.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
const
webpackConfig = require('./webpack.config.prod'),
helpers = require('./helpers');

webpackConfig.output = {
path: helpers.root('/dist'),
filename: 'index.js',
library: '[name]',
libraryTarget: 'umd',
umdNamedDefine: true
};

webpackConfig.externals = {
'axios': 'axios',
'vue': 'vue',
'vue-class-component': 'vue-class-component',
'vue-property-decorator': 'vue-property-decorator',
'vue-router': 'vue-router'
};

module.exports = webpackConfig;
14,274 changes: 0 additions & 14,274 deletions template/package-lock.json

This file was deleted.

16 changes: 12 additions & 4 deletions template/package.json
Original file line number Diff line number Diff line change
@@ -4,29 +4,37 @@
"version": "1.0.0",
"author": "{{ author }}",
"private": true,
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"engines": {
"node": ">=6",
"npm": ">=3"
},
"scripts": {
"build": "cross-env NODE_ENV=production npm run clean && npm run test && npm run compile",
"prebuild:production": "cross-env NODE_ENV=production npm run clean && npm run test",
"build": "npm run prebuild:production && npm run compile",
"module": "npm run prebuild:production && npm run compile:module",
"build:parts": "npm run sass && npm run compile",
"ci:teamcity": "karma --env=tc start config/karma.coverage.js && npm run coverage:remap",
"ci:jenkins": "karma --env=jk start config/karma.coverage.js && npm run coverage:remap",
"clean": "rimraf dist && rimraf coverage",
"compile": "webpack --config config/webpack.config.prod.js",
"compile:module": "webpack --config config/webpack.config.module.js",
"prepublishOnly": "npm run module",
"coverage": "npm run coverage:run && npm run coverage:remap && npm run coverage:open",
"coverage:open": "opn coverage/html-ts/index.html",
"coverage:remap": "remap-istanbul -i coverage/json/coverage-final.json -o coverage/html-ts -t html",
"coverage:run": "cross-env NODE_ENV=development karma start config/karma.coverage.js",
"dev": "webpack-dev-server --config config/webpack.config.dev.js --hot --inline",
"lint": "tslint src/**/*.ts",
"serve": "http-server dist/ -g -o",
"serve": "superstatic dist --port 8080 --host 0.0.0.0 --config superstatic.json",
"test": "cross-env NODE_ENV=development karma start config/karma.unit.js",
"test:debug": "cross-env NODE_ENV=development karma start config/karma.debug.js",
"test:watch": "cross-env NODE_ENV=development karma start config/karma.unit.js --singleRun=false --auto-watch"
},
"dependencies": {
"axios": "~0.17.1",
"superstatic": "^5.0.1",
"uiv": "~0.17.0",
"vue": "~2.5.13",
"vue-class-component": "~6.1.2",
@@ -52,13 +60,13 @@
"favicons-webpack-plugin": "0.0.7",
"file-loader": "~1.1.6",
"html-webpack-plugin": "~2.30.1",
"http-server": "~0.11.1",
"istanbul-instrumenter-loader": "~3.0.0",
"jsdom": "^11.5.1",
"json-loader": "~0.5.7",
"karma": "~2.0.0",
"karma-chai": "~0.1.0",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage": "~1.1.1",
"karma-jsdom-launcher": "^6.1.2",
"karma-junit-reporter": "~1.2.0",
"karma-mocha": "~1.3.0",
"karma-mocha-reporter": "~2.2.5",
36 changes: 20 additions & 16 deletions template/src/router.ts
Original file line number Diff line number Diff line change
@@ -26,21 +26,25 @@ if (process.env.ENV === 'development' && module.hot) {
module.hot.accept('./components/list', () => reload(listModuleId, (require('./components/list') as any).ListComponent)))
}{{/hotReload}}

Vue.use(VueRouter)
export function createRoutes(prefix: string = ''): RouteConfig[] {
return [
{
path: prefix + '/',
component: homeComponent,
},
{
path: prefix + '/about',
component: aboutComponent,
},
{
path: prefix + '/list',
component: listComponent,
}
];
}

export const createRoutes: () => RouteConfig[] = () => [
{
path: '/',
component: homeComponent
},
{
path: '/about',
component: aboutComponent
},
{
path: '/list',
component: listComponent
}
]

export const createRouter = () => new VueRouter({ mode: 'history', routes: createRoutes() })
export const createRouter = () => {
Vue.use(VueRouter);
return new VueRouter({mode: 'history', routes: createRoutes()});
};
6 changes: 6 additions & 0 deletions template/superstatic.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"rewrites": [
{"source":"/**","destination":"/index.html"}
],
"compression": true
}
11 changes: 10 additions & 1 deletion template/tsconfig.json
Original file line number Diff line number Diff line change
@@ -4,10 +4,19 @@
"dom",
"es5",
"es2015",
"es2015.promise"
"es2016",
"es2017",
"es6",
"esnext"
],
"exclude": [
"typings/index.d.ts",
"typings/index",
"node_modules"
],
"module": "esnext",
"moduleResolution": "node",
"declaration": true,
"target": "es5",
"sourceMap": true,
"emitDecoratorMetadata": true,