这期内容当中小编将会给大家带来有关使用webpack2怎么搭建一个angular2项目,文章内容丰富且以专业的角度为大家分析和叙述,阅读完这篇文章希望大家可以有所收获。
成都创新互联公司长期为近千家客户提供的网站建设服务,团队从业经验10年,关注不同地域、不同群体,并针对不同对象提供差异化的产品和服务;打造开放共赢平台,与合作伙伴共同营造健康的互联网生态环境。为水磨沟企业提供专业的成都网站设计、做网站、成都外贸网站建设公司,水磨沟网站改版等技术服务。拥有10余年丰富建站经验和众多成功案例,为您定制开发。
npm install
,安装依赖包
npm run dev
,启动本地工程,在localhost:1699进行预览
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配置文件开发版:
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中,据说在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) })
上述就是小编为大家分享的使用webpack2怎么搭建一个angular2项目了,如果刚好有类似的疑惑,不妨参照上述分析进行理解。如果想知道更多相关知识,欢迎关注创新互联行业资讯频道。
本文标题:使用webpack2怎么搭建一个angular2项目
分享路径:https://www.cdcxhl.com/article46/igcjhg.html
成都网站建设公司_创新互联,为您提供、移动网站建设、网站营销、网站内链、手机网站建设、网站策划
声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联