Skip to content

Commit

Permalink
feat: export name and version on module (#129)
Browse files Browse the repository at this point in the history
add export of name and version of library.
  • Loading branch information
OrenMe committed Nov 7, 2017
1 parent 1bef5d6 commit 8f88c26
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
4 changes: 3 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@
},
"globals": {
"should": true,
"sinon": true
"sinon": true,
"__VERSION__": true,
"__NAME__": true
},
"rules": {
"mocha-no-only/mocha-no-only": "off",
Expand Down
4 changes: 4 additions & 0 deletions src/ui-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ import liveUI from './ui-presets/live';

import './styles/style.scss';

declare var __VERSION__: string;
declare var __NAME__: string;

type UIPreset = {
template: (props: Object) => any;
condition?: (state: Object) => boolean;
Expand Down Expand Up @@ -113,4 +116,5 @@ class UIManager {
}

export default UIManager;
export {__VERSION__ as VERSION, __NAME__ as NAME};

15 changes: 14 additions & 1 deletion webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,19 @@
const webpack = require("webpack");
const path = require("path");
const PROD = (process.env.NODE_ENV === 'production');
const packageData = require("./package.json");

let plugins = [
new webpack.DefinePlugin({
__VERSION__: JSON.stringify(packageData.version),
__NAME__: JSON.stringify(packageData.name),
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV || 'development')
})
];

if (PROD) {
plugins.push(new webpack.optimize.UglifyJsPlugin({sourceMap: true}));
}

module.exports = {
context: __dirname + "/src",
Expand All @@ -15,7 +28,7 @@ module.exports = {
devtoolModuleFilenameTemplate: "./ui/[resource-path]",
},
devtool: 'source-map',
plugins: PROD ? [new webpack.optimize.UglifyJsPlugin({sourceMap: true})] : [],
plugins: plugins,
module: {
rules: [
{
Expand Down

0 comments on commit 8f88c26

Please sign in to comment.