这期内容当中小编将会给大家带来有关使用webpack2怎么搭建一个angular2项目,文章内容丰富且以专业的角度为大家分析和叙述,阅读完这篇文章希望大家可以有所收获。
创新互联成立与2013年,先为讷河等服务建站,讷河等地企业,进行企业商务咨询服务。为讷河企业网站制作PC+手机+微官网三网同步一站式服务解决您的所有建站问题。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项目了,如果刚好有类似的疑惑,不妨参照上述分析进行理解。如果想知道更多相关知识,欢迎关注创新互联网站建设公司行业资讯频道。
另外有需要云服务器可以了解下创新互联建站www.cdcxhl.com,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。
售后响应及时
7×24小时客服热线数据备份
更安全、更高效、更稳定价格公道精准
项目经理精准报价不弄虚作假合作无风险
重合同讲信誉,无效全额退款