Created
February 1, 2016 19:35
-
-
Save MartinTale/4ca0043f3b689fbd898b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Escape special characters in the given string of html. | |
* | |
* @param {String} html | |
* @return {String} | |
*/ | |
module.exports = { | |
escape: function(html) { | |
return String(html) | |
.replace(/&/g, '&') | |
.replace(/"/g, '"') | |
.replace(/\'/g, ''') | |
.replace(/</g, '<') | |
.replace(/>/g, '>'); | |
}, | |
/** | |
* Unescape special characters in the given string of html. | |
* | |
* @param {String} html | |
* @return {String} | |
*/ | |
unescape: function(html) { | |
return String(html) | |
.replace(/&/g, '&') | |
.replace(/"/g, '"') | |
.replace(/'/g, '\'') | |
.replace(/</g, '<') | |
.replace(/>/g, '>'); | |
} | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "test-package", | |
"version": "1.0.0", | |
"description": "Test package", | |
"main": "index.js", | |
"scripts": { | |
"dev": "webpack --watch --progress --colors --config webpack.dev.config.js", | |
"build": "webpack && webpack --config webpack.dev.config.js", | |
"test": "echo \"Error: no test specified\" && exit 1" | |
}, | |
"devDependencies": { | |
"babel-core": "^6.4.5", | |
"babel-eslint": "^4.1.6", | |
"babel-loader": "^6.2.1", | |
"babel-preset-es2015": "^6.3.13", | |
"eslint": "^1.10.3", | |
"eslint-loader": "^1.2.1", | |
"webpack": "^1.12.12", | |
"escope": "3.3.0" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var webpack = require('webpack'); | |
var uglifyJsPlugin = webpack.optimize.UglifyJsPlugin; | |
module.exports = { | |
debug: true, | |
entry: './index.js', | |
output: { | |
path: '.', | |
filename: "test-package.min.js", | |
library: "test-package", | |
libraryTarget: "umd" | |
}, | |
module: { | |
preLoaders: [ | |
{ | |
test: /\.js$/, | |
loader: 'eslint-loader', | |
exclude: /node_modules/ | |
} | |
], | |
loaders: [ | |
{ | |
test: /\.js$/, | |
loader: 'babel-loader', | |
exclude: /node_modules/, | |
query: { | |
presets: ['es2015'] | |
} | |
} | |
] | |
}, | |
plugins: [ | |
new uglifyJsPlugin({ | |
compress: { | |
warnings: false | |
} | |
}) | |
], | |
eslint: { | |
configFile: '.eslintrc' | |
} | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var webpack = require('webpack'); | |
module.exports = { | |
debug: true, | |
entry: './index.js', | |
output: { | |
path: '.', | |
filename: "test-package.js", | |
library: "test-package", | |
libraryTarget: "umd" | |
}, | |
module: { | |
preLoaders: [ | |
{ | |
test: /\.js$/, | |
loader: 'eslint-loader', | |
exclude: /node_modules/ | |
} | |
], | |
loaders: [ | |
{ | |
test: /\.js$/, | |
loader: 'babel-loader', | |
exclude: /node_modules/, | |
query: { | |
presets: ['es2015'] | |
} | |
} | |
] | |
}, | |
eslint: { | |
configFile: '.eslintrc' | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment