MEAN 응용 프로그램 클라이언트 측이 anular2 빌드 웹 팩에 있습니다.Angular2 + Webpack : 공급 업체 번들을 최적화하는 방법
초기 요청으로 서버에서 index.html을 제공하는 경우 공급 업체 모듈 JS 파일이 3MB 이상이므로 프로덕션 환경에서 응용 프로그램을로드하는 데 5 또는 6 초 이상 걸립니다.
어떻게하면 최적화 할 수 있습니까? 공급 업체의 JS 파일을 분리하고 싶습니다. 다음은 내가 내 응용 프로그램의 JS를 포함 bundle.js 및 bundle.map.js를 얻을 수 있습니다 내 webpack.config.js
const webpack = require('webpack');
const production = process.env.NODE_ENV === "production";
const autoprefixer = require('autoprefixer');
const path = require("path");
const config = {
entry: {
'app': './client/app.ts',
'vendor': './client/vendor.ts' },
debug: !production,
devtool: production ? null : "source-map",
output: {
path: "./dist",
filename: "bundle.js" },
plugins: [
new webpack.optimize.CommonsChunkPlugin('vendor', 'vendor.bundle.js') ],
resolve: {
extensions: ['', '.ts'] },
module: {
loaders: [
{ test: /\.ts$/, loader: 'ts-loader' },
{ test: /\.html$/, loader: 'raw'},
{ test: /\.scss$/, include: [ path.resolve(__dirname, 'client/app/components') ], loader: 'style!css!postcss!sass' }
],
noParse: [ path.join(__dirname, 'node_modules', 'angular2', 'bundles') ] }, postcss: [ autoprefixer ] };
module.exports = config;
내 vendor.ts
파일 다음
import 'core-js/es6';
import 'core-js/es7/reflect';
require('zone.js/dist/zone');
import 'ts-helpers';
import '@angular/platform-browser-dynamic';
import '@angular/core';
import '@angular/common';
import '@angular/http';
import '@angular/router';
import 'socket.io-client';
// RxJS
import 'rxjs/add/operator/map';
import 'rxjs/add/operator/mergeMap';
import './assets/vendor/bootstrap';
import './assets/vendor/fontawesome.scss';
건물 프로젝트 vendor.bundle.js 및 vendor.bundle.map.js이 포함됩니다 타사 JS
나는 모든 SCS들이 ditribution 별도의있는 style.css에서 컴파일해야 별도로뿐만 아니라이 vendor.js
각 라이브러리를 컴파일합니다.
감사합니다.
이 질문에 행운을 빕니다. 나는 또한 내 질문의 ans를 찾으려고 노력하고있다. http://stackoverflow.com/questions/43500349/angular2-bundle-node-modules-only-and-not-application-code –