Update build chain

This commit is contained in:
Thomas Lovén 2019-11-05 10:52:39 +01:00
parent d671cdbdfe
commit f674ff567b
9 changed files with 4113 additions and 49 deletions

3
.gitignore vendored
View File

@ -1,4 +1 @@
node_modules/ node_modules/
package-lock.json
package.json
webpack.config.js

View File

@ -1,42 +0,0 @@
AUTHOR := Thomas Lovén
CARD_TOOLS := $(PWD)/../card-tools
PACKAGE := $(shell basename $(CURDIR))
PACKAGE := $(PACKAGE:lovelace-%=%)
DOCKER_CMD:=docker run --rm -v $(CARD_TOOLS):/card-tools:ro -v $(PWD):/usr/src/$(PACKAGE) -w="/usr/src/$(PACKAGE)" node:11
build: setup
$(DOCKER_CMD) npm run build
dev: setup
$(DOCKER_CMD) npm run watch
setup: package.json package-lock.json webpack.config.js
clean:
rm package.json package-lock.json webpack.config.js
rm -r node_modules
rm $(PACKAGE).js
define WEBPACK_CONFIG
const path = require('path');
module.exports = {
entry: './src/main.js',
mode: 'production',
output: {
filename: '$(PACKAGE).js',
path: path.resolve(__dirname)
}
};
endef
export WEBPACK_CONFIG
webpack.config.js:
echo "$$WEBPACK_CONFIG" >> $@
package-lock.json:
$(DOCKER_CMD) npm install webpack webpack-cli --save-dev
package.json:
$(DOCKER_CMD) /bin/bash -c "npm set init.license 'MIT' && npm set init.author.name '$(AUTHOR)' && npm init -y"
$(DOCKER_CMD) sed -E -i -e '/^ +"main"/d' -e '/^ +"scripts"/a\ "build": "webpack",' -e '/^ +"scripts"/a\ "watch": "webpack --watch --mode=development",' -e '2a\ "private": true,' $@

4078
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

21
package.json Normal file
View File

@ -0,0 +1,21 @@
{
"name": "card-mod",
"private": true,
"version": "1.0.0",
"description": "",
"scripts": {
"build": "webpack",
"watch": "webpack --watch --mode=development",
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "Thomas Lovén",
"license": "MIT",
"devDependencies": {
"webpack": "^4.33.0",
"webpack-cli": "^3.3.2"
},
"dependencies": {
"card-tools": "github:thomasloven/lovelace-card-tools"
}
}

View File

@ -1,4 +1,4 @@
import {subscribeRenderTemplate} from "/card-tools/templates.js"; import {subscribeRenderTemplate} from "card-tools/src/templates.js";
class CardMod extends HTMLElement { class CardMod extends HTMLElement {

View File

@ -1,4 +1,4 @@
import {fireEvent} from "/card-tools/event.js"; import {fireEvent} from "card-tools/src/event.js";
import {applyStyle} from "./apply-style.js"; import {applyStyle} from "./apply-style.js";
customElements.whenDefined('ha-card').then(() => { customElements.whenDefined('ha-card').then(() => {

View File

@ -1,4 +1,4 @@
import {fireEvent} from "/card-tools/event.js"; import {fireEvent} from "card-tools/src/event.js";
import {applyStyle} from "./apply-style.js"; import {applyStyle} from "./apply-style.js";
customElements.whenDefined('hui-entities-card').then(() => { customElements.whenDefined('hui-entities-card').then(() => {

View File

@ -1,4 +1,4 @@
import {fireEvent} from "/card-tools/event.js"; import {fireEvent} from "card-tools/src/event.js";
import {applyStyle} from "./apply-style.js"; import {applyStyle} from "./apply-style.js";
customElements.whenDefined('hui-glance-card').then(() => { customElements.whenDefined('hui-glance-card').then(() => {

10
webpack.config.js Normal file
View File

@ -0,0 +1,10 @@
const path = require('path');
module.exports = {
entry: './src/main.js',
mode: 'production',
output: {
filename: 'card-mod.js',
path: path.resolve(__dirname)
}
};