我正在尝试使用webpack编译Angular2;这是我的设置:我有一个vendor.ts文件,我有:
import 'es6-shim/es6-shim.min';
import 'reflect-metadata/Reflect.js';
import 'zone.js/dist/zone';
import '@angular/platform-browser';
import '@angular/platform-browser-dynamic';
import '@angular/core';
import '@angular/common';
import '@angular/http';
import '@angular/router-deprecated';
我的webpack.config.js
:
"use strict";
let path = require('path');
let webpack = require("webpack");
let CommonsChunkPlugin = webpack.optimize.CommonsChunkPlugin;
let ProvidePlugin = webpack.ProvidePlugin;
let UglifyJsPlugin = webpack.optimize.UglifyJsPlugin;
module.exports = {
devtool: 'source-map',
debug: true, // set false in production
cache: true,
entry: {
vendor: './app/vendor.ts',
app: './app/main.ts'
},
output: {
filename: './public/assets/js/[name].js'
},
plugins: [
new webpack.optimize.OccurenceOrderPlugin(true),
new webpack.optimize.CommonsChunkPlugin({name: 'vendor', filename: './public/assets/js/vendor.js', minChunks: Infinity}),
new UglifyJsPlugin({
compress: {
warnings: false
}
})
],
module: {
loaders: [
{
test: /\.ts$/,
loader: 'ts-loader',
query: {
'ignoreDiagnostics': [
2403, // 2403 -> Subsequent variable declarations
2300, // 2300 -> Duplicate identifier
2374, // 2374 -> Duplicate number index signature
2375 // 2375 -> Duplicate string index signature
]
},
exclude: [/\.(spec|e2e)\.ts$/, /node_modules\/(?!(ng2-.+))/]
}
]
},
resolve: {
extensions: ["", ".ts", ".js"]
}
};
所以,一切都很好,webpack正在编译这些东西,但它太慢了。这需要15089毫秒。我打算将其添加为gulp任务,但这不起作用,我必须等待每次保存3-5秒。是否可以设置如果块没有改变,以防止编译?这将大大提高性能。提前感谢您的帮助。
答案 0 :(得分:4)
您必须停用 theScroll.contentSize = CGSizeMake(theScroll.contentSize.width, CGRectGetMaxY(label.frame)+30.0f);
个插件,将<html lang="">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title></title>
</head>
<body>
<input test="PROD" value="2" type="text">
<input test="DEV" value="3" type="text">
<input type="button" value="Write It" onclick="writeIt()"/>
</body>
</html>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
<script>
function writeIt() {
$.each($('input').attr('test'), function () {
var testdata = $(this).attr('test');
//$(this).val(testdata);
console.log(testdata);
});
}
</script>
切换为webpack.optimize.*
并将devtool
添加到eval
查询。