From 57a81abcfe7070f54188f17a629fc8794b738e39 Mon Sep 17 00:00:00 2001 From: Thomas Jarrand Date: Sat, 10 Jun 2017 19:03:33 +0200 Subject: [PATCH] Added webpack build for node support --- .babelrc | 3 ++- .gitignore | 4 +++- LICENSE | 2 +- README.md | 4 ++-- package.json | 38 ++++++++++++++++++++++++-------------- webpack.config.js | 33 +++++++++++++++++++++++++++++++++ 6 files changed, 65 insertions(+), 19 deletions(-) create mode 100644 webpack.config.js diff --git a/.babelrc b/.babelrc index c13c5f6..b30d23d 100644 --- a/.babelrc +++ b/.babelrc @@ -1,3 +1,4 @@ { - "presets": ["es2015"] + "presets": ["es2015"], + "plugins": ["transform-class-properties"] } diff --git a/.gitignore b/.gitignore index 1e509d9..a3b9e56 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ -/node_modules/ +/node_modules +/dist yarn.lock +package-lock.json diff --git a/LICENSE b/LICENSE index 3e71015..a5431f0 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2017 Elao +Copyright (c) 2017 élao Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index 900f5f4..bea672b 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ Microscopic dependency injection container ## Installation - yarn add elao-container.js + npm install @elao/container.js ## Usage @@ -28,7 +28,7 @@ Set up your container like that: ```js // my-container.js -import Container from 'elao-container.js'; +import Container from '@elao/container.js'; import MyApiClient from './MyApiClient'; const container = new Container(); diff --git a/package.json b/package.json index c935340..c1d60e9 100644 --- a/package.json +++ b/package.json @@ -1,30 +1,40 @@ { - "name": "elao-container.js", - "version": "1.0.0", + "name": "@elao/container.js", + "version": "2.0.0", "description": "Microscopic dependency injection container", - "main": "src/Container.js", + "keywords": [ + "dependency", + "injection", + "container", + "service" + ], + "main": "dist/container.js", "repository": { "type": "git", "url": "git+https://github.com/Elao/container.js.git" }, - "author": "Thomas Jarrand ", + "author": "Thomas Jarrand (http://thomas.jarrand.fr)", "license": "MIT", + "copyright": "Copyright 2017 élao", "bugs": { "url": "https://github.com/Elao/container.js/issues" }, "homepage": "https://github.com/Elao/container.js#readme", "scripts": { - "test": "jest" + "test": "jest", + "build": "NODE_ENV=production webpack", + "start": "NODE_ENV=dev webpack --watch" }, - "keywords": [ - "dependency", - "injection", - "container", - "service" - ], "devDependencies": { - "babel-jest": "^19.0.0", - "babel-preset-es2015": "^6.24.0", - "jest": "^19.0.2" + "babel": "^6.23.0", + "babel-core": "^6.25.0", + "babel-eslint": "^7.2.3", + "babel-jest": "^20.0.3", + "babel-loader": "^7.0.0", + "babel-plugin-transform-class-properties": "^6.24.1", + "babel-polyfill": "^6.23.0", + "babel-preset-es2015": "^6.24.1", + "jest": "^20.0.4", + "webpack": "^2.6.1" } } diff --git a/webpack.config.js b/webpack.config.js new file mode 100644 index 0000000..942226c --- /dev/null +++ b/webpack.config.js @@ -0,0 +1,33 @@ +const webpack = require('webpack'); +const meta = require('./package.json'); + +module.exports = { + entry: './src/Container.js', + module: { + loaders: [ + { + test: /\.js$/, + exclude: /node_modules/, + loader: 'babel-loader' + }, + ] + }, + output: { + path: __dirname + '/dist', + filename: 'container.js', + library: 'Container', + libraryTarget: 'umd', + }, + devServer: { + contentBase: './dist', + }, + devtool: 'source-map', + plugins: [ + new webpack.optimize.UglifyJsPlugin(), + new webpack.BannerPlugin([ + `${meta.name} - ${meta.version}`, + `${meta.homepage}`, + `${meta.copyright}`, + ].join('\n')) + ] +};