Skip to content

Commit

Permalink
feat: export name and version on module (#13)
Browse files Browse the repository at this point in the history
add export of name and version of library
  • Loading branch information
OrenMe authored Nov 8, 2017
1 parent 8c30b9d commit 8490b14
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 2 deletions.
4 changes: 3 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
},
"globals": {
"should": true,
"sinon": true
"sinon": true,
"__VERSION__": true,
"__NAME__": true
},
"rules": {
"mocha-no-only/mocha-no-only": "off",
Expand Down
9 changes: 9 additions & 0 deletions karma.conf.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
const webpack = require("webpack");
const packageData = require("./package.json");

const isWindows = /^win/.test(process.platform);
const isMacOS = /^darwin/.test(process.platform);
// Create custom launcher in case running with Travis
Expand Down Expand Up @@ -42,6 +45,12 @@ module.exports = function (config) {
'coverage'
],
webpack: {
plugins: [
new webpack.DefinePlugin({
__VERSION__: JSON.stringify(packageData.version),
__NAME__: JSON.stringify(packageData.name)
})
],
devtool: 'inline-source-map',
module: {
rules: [{
Expand Down
5 changes: 5 additions & 0 deletions src/youbora.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,11 @@ export default class Youbora extends BasePlugin {
}
}

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

export {__VERSION__ as VERSION, __NAME__ as NAME};

/**
* Register the plugin in player's registry.
*/
Expand Down
14 changes: 13 additions & 1 deletion webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,18 @@
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)
})
];

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

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

0 comments on commit 8490b14

Please sign in to comment.