我正在编写ES6代码并将其转换为使用Babel的ES5,然后使用Uglify进行缩小.全部通过gulp与webpack一起运行.我想使用外部源映射(以尽可能减小文件大小).
gulp任务非常基本 - 所有时髦的东西都在webpack配置中:
var gulp = require("gulp");
var webpack = require("gulp-webpack");
gulp.task("js:es6", function () {
return gulp.src(path.join(__dirname, "PTH", "TO", "SRC", "index.js"))
.pipe(webpack(require("./webpack.config.js")))
.pipe(gulp.dest(path.join(__dirname, "PTH", "TO", "DEST")));
});
Run Code Online (Sandbox Code Playgroud)
webpack.config.js:
var path = require("path");
var webpack = require("webpack");
module.exports = {
output: {
filename: "main.js",
sourceMapFilename: "main.js.map"
},
devtool: "#inline-source-map",
module: {
loaders: [
{ test: path.join(__dirname, "PTH", "TO", "SRC"),
loader: "babel-loader" }
]
},
plugins: [
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false
},
output: {
comments: false,
semicolons: true
}, …
Run Code Online (Sandbox Code Playgroud) 我在Ubuntu 13.10中的Apache 2.4中遇到了问题.我尝试将Document Root更改为/ home/fandi/public_html并且一切正常.但我尝试在我的public_html /我创建文件夹得到这样的错误:
[Sat Jan 25 10:59:50.149441 2014] [autoindex:error] [pid 1093] [client 127.0.0.1:39901] AH01276: Cannot serve directory /home/fandi/public_html/report_php/: No matching DirectoryIndex (index.html,index.cgi,index.pl,index.php,index.xhtml,index.htm) found, and server-generated directory index forbidden by Options directive
Run Code Online (Sandbox Code Playgroud)
我必须创建文件index.html
,index.php
以及其他index.xxx
文件.
默认情况下,它必须显示目录索引.如何启用目录索引?
这是我的档案000-default.conf
:
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /home/fandi/public_html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<Directory "/home/fandi/public_html">
Options All
AllowOverride All
Require all granted
Options Indexes FollowSymLinks
</Directory>
</VirtualHost>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
Run Code Online (Sandbox Code Playgroud)
请帮助,谢谢^^之前
使用Tape时如何运行特定测试并忽略所有其他测试?
根据各种来源(2ality,esdiscuss),应该能够将mixins添加到类中:
编辑发现类方法不可枚举,因此无法工作.编辑了下面的代码,但仍然没有快乐
class CartoonCharacter {
constructor(author) {
this.author = author;
}
drawnBy() {
console.log("drawn by", this.author);
}
}
// THIS CANNOT WORK
// class methods are not enumerable
// class Human {
// haveFun() {
// console.log("drinking beer");
// }
// }
let Human = Object.create({}, {
haveFun: {
enumerable: true,
value: function () {
console.log("drinking beer");
}
}
});
class Simpson extends Object.assign(CartoonCharacter, Human) {
constructor(author) {
super(author);
}
}
let homer = new …
Run Code Online (Sandbox Code Playgroud) 此页面:http://googleappsupdates.blogspot.de/2012/06/apps-script-in-docs-list.html 表示
Google Apps脚本项目现已包含在Google云端硬盘的文档列表中. - 您的项目现在存储在Google云端硬盘中,可以像任何其他文件一样进行共享.
嗯,它不适合我.我可以通过以下链接https://script.google.com/macros/s/AKfycbyAo3y-3让应用运行 ...但我无法在Google云端硬盘中看到它,无论是桌面版还是Android版.我想通过单击列表中的项目来访问它,因为我想在我的手机上找到它,不能输入那些长的随机URL.
当我在桌面上查看Google云端硬盘,并在"所有者,类型,更多>>"下搜索时,它甚至没有像列表中那样远程显示Web App.
我使用磁带在 JavaScript 中进行测试,但在某些情况下,我想设置一些在文件内的所有测试中可用的配置变量。类似于 PhpUnit 中可用的 setUp 和tearDown 方法。这些方法将分别在文件中的每个测试之前和之后执行。
例如:
test("setUp", function(t){
var person = {name: 'Jose', programmer: true};
});
test("Name isn't undefined", function(){
t.notEqual(person.name, undefined);
});
test("Is a programmer", function(t){
t.ok(person.programmer);
});
test("tearDown", function(){
//Do something else
});
Run Code Online (Sandbox Code Playgroud) 我有一个.tags
包含链接和标题的父 div ( )。
父 div 设置为display: flex;
with flex-wrap: wrap;
。
我希望链接元素换到一个新行,在发生换行效果时清除标题。
我曾尝试flex-grow: 1
在标题上使用,但这使它始终将链接推送到屏幕右侧,这不是我所追求的。
我已经附上了到目前为止的代码,但这里是Codepen的链接
我正在努力实现的目标:
默认- 屏幕的宽度足够大,所以没有任何包裹,所有内容都在一行中 >
Wrapped - 屏幕的宽度更小,发生了 wrap - 标题现在有 100% 的宽度并且链接清除了它 >
请注意,链接的数量可能会有所不同。
.container {
background: lightgray;
width: 100%;
}
.tags {
display: flex;
flex-wrap: wrap;
align-items: center;
justify-content: flex-start;
}
.tags span {
margin: 1rem;
}
.tags .tag {
margin: 0.2rem;
padding: 0.2rem;
background: dodgerblue;
color: white;
}
Run Code Online (Sandbox Code Playgroud)
<div class="container">
<div class="tags">
<span>Tagged in:</span> …
Run Code Online (Sandbox Code Playgroud)有谁知道为什么
"why?? <abc> and <a b c> and <a b>".replace( /<([^>]+)>/g, "\$$1" );
Run Code Online (Sandbox Code Playgroud)
返回
"why?? $1 and $1 and $1"
Run Code Online (Sandbox Code Playgroud)
绝对的
"why?? $abc and $a b c and $a b"
Run Code Online (Sandbox Code Playgroud)
没有转义$,结果如预期
"why?? <abc> and <a b c> and <a b>".replace( /<([^>]+)>/g, "$1" )
//"why?? abc and a b c and a b"
Run Code Online (Sandbox Code Playgroud)
我试过各种各样的黑客,包括例如
"why?? <abc> and <a b c> and <a b>".replace( /<([^>]+)>/g, String.fromCharCode( 36 ) + "$1" );
Run Code Online (Sandbox Code Playgroud)
最后我设法使用函数作为替换字符串获得我想要的输出(见下文),但我想知道我做错了什么.提前致谢.
"why?? <abc> and <a b c> and <a b>".replace( /<([^>]+)>/g, …
Run Code Online (Sandbox Code Playgroud) 我从 Python 3 转向 Node.js,想知道 Node.js 是否有一些我可以使用的东西,它与 Python 的基本相同,input
例如,假设我们有以下代码:
def newUser(user = None, password = None):
if not user: user = input("New user name: ")
if not password: password = input("Password: ")
return "Welcome, your user name is %s and your password is %s" % (user, password)
# Option one
>>> newUser(user = "someone", password = "myPassword")
'Welcome your user name is someone and your password is myPassword'
# Option Two
>>> newUser()
New User name: someone
Password: …
Run Code Online (Sandbox Code Playgroud) 使用karma + babel + webpack运行ES6单元测试.我使用webpack包来定位和转换ES6.这一切都有效,但只要在任何测试文件中出现错误,我都会收到消息,但没有指出错误发生的地方,比如
Uncaught TypeError: Cannot read property 'querySelector' of null
at /pth/to/test.bundle.js:13256
Run Code Online (Sandbox Code Playgroud)
它始终是 /pth/to/test.bundle.js:xxxx
.知道如何让它显示更多有用的消息吗?
这是我的配置
module.exports = function(config) {
config.set({
browsers: ["Chrome"],
files: [
{
pattern: "test.bundle.js",
watched: false
}],
frameworks: ["jasmine-jquery", "jasmine-ajax", "jasmine"],
preprocessors: {,
"test.bundle.js": ["webpack"]
},
reporters: ["dots"],
singleRun: false,
webpack: {
module: {
loaders: [{
test: /\.js/,
exclude: /node_modules/,
loader: "babel-loader?cacheDirectory&optional[]=runtime"
}]
},
watch: true
},
webpackServer: {
noInfo: true
}
});
};
Run Code Online (Sandbox Code Playgroud)
还有我的test.bundle.js
var context = require.context("./src", true, /.+(-helpers|\.test)\.js$/);
context.keys().forEach(context);
Run Code Online (Sandbox Code Playgroud) javascript ×7
babeljs ×2
node.js ×2
node.js-tape ×2
tap ×2
unit-testing ×2
webpack ×2
apache2.4 ×1
composition ×1
css ×1
ecmascript-6 ×1
flexbox ×1
gulp ×1
html ×1
karma-runner ×1
minify ×1
mixins ×1
regex ×1
testing ×1
traits ×1
webserver ×1