国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 編程 > JavaScript > 正文

詳解用webpack2搭建angular2的項(xiàng)目

2019-11-19 16:17:16
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友

webpack2和angular2搭建的項(xiàng)目

github地址:項(xiàng)目鏈接

  1. npm install,安裝依賴(lài)包
  2. npm run dev,啟動(dòng)本地工程,在localhost:1699進(jìn)行預(yù)覽
package.json{ "name": "angular-webpack", "version": "1.0.0", "description": "webpack2 & angular2", "scripts": {  "dev": "babel-node ./src/config/dev.js" }, "author": "Travis Lee", "license": "ISC", "dependencies": {  "@angular/common": "~4.0.0",  "@angular/compiler": "~4.0.0",  "@angular/core": "~4.0.0",  "@angular/forms": "~4.0.0",  "@angular/http": "~4.0.0",  "@angular/platform-browser": "~4.0.0",  "@angular/platform-browser-dynamic": "~4.0.0",  "@angular/router": "~4.0.0",  "core-js": "^2.4.1",  "es6-shim": "^0.35.3",  "reflect-metadata": "^0.1.8",  "rxjs": "5.0.1",  "zone.js": "^0.8.4" }, "devDependencies": {  "babel-core": "^6.25.0",  "babel-loader": "^7.1.0",  "babel-preset-es2015": "^6.24.1",  "clean-webpack-plugin": "^0.1.16",  "css-loader": "^0.28.4",  "extract-text-webpack-plugin": "^2.1.2",  "path": "^0.12.7",  "style-loader": "^0.18.2",  "ts-loader": "^2.1.0",  "typescript": "^2.3.4",  "typings": "^2.1.1",  "uglifyjs-webpack-plugin": "^0.4.6",  "webpack": "^2.6.1",  "webpack-dev-server": "^2.5.0",  "webpack-merge": "^4.1.0" }}

webpack配置文件開(kāi)發(fā)版:

import path from 'path'import config from "./webpack.config"import merge from "webpack-merge"import webpack from "webpack"import webpackDevServer from "webpack-dev-server"import { format } from 'util'let PORT = 1699;let PUBLIC_PATH = "http://localhost:" + PORT + "/";let webpackConifg = merge(config, {  devtool: "source-map",  //debug: true, webpack2 已切換到plugins中,據(jù)說(shuō)在3中將取消  entry: {    main: [      format("webpack-dev-server/client?%s", PUBLIC_PATH),      "webpack/hot/dev-server",      "./src/main.ts"    ]  },  output: {    path: path.resolve(__dirname, '../../dist'),    publicPath: PUBLIC_PATH,    filename: '[name].js'  },  plugins: [    new webpack.HotModuleReplacementPlugin()  ]})const compiler = webpack(webpackConifg);new webpackDevServer(compiler, {  inline: true,  hot: true,  port: PORT,  stats: {    colors: true  }}).listen(PORT, 'localhost', (err) => {  console.log(123)})

搭建中遇到的問(wèn)題:

The URL 'localhost:1699/sockjs-node' is invalid, 

該問(wèn)題是由于webpack配置文件中的publicPath前邊沒(méi)有加http://,導(dǎo)致url解析失敗

Uncaught reflect-metadata shim is required when using class decorators,

 這個(gè)問(wèn)題是由于main.ts文件中沒(méi)有引入 reflect-metadata和zone.js


以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持武林網(wǎng)。

發(fā)表評(píng)論 共有條評(píng)論
用戶(hù)名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 沭阳县| 长治市| 阿克苏市| 唐河县| 黄陵县| 宕昌县| 渭源县| 都江堰市| 通州市| 怀宁县| 资阳市| 德州市| 江北区| 静宁县| 宕昌县| 资源县| 象州县| 于都县| 康定县| 龙岩市| 枣强县| 墨竹工卡县| 扎赉特旗| 饶阳县| 泾阳县| 依兰县| 云龙县| 焦作市| 碌曲县| 乳山市| 巫山县| 亚东县| 金华市| 盘锦市| 湘潭县| 永济市| 齐河县| 高密市| 边坝县| 东海县| 承德市|