[AngularJS + Webpack] Production Setup
Using Angular with webpack makes the production build a breeze. Simply alter your webpack configuration at runtime based on an environment variable, and you're good to go.
package.json:
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "webpack-dev-server --content-base app",
"build": "set NODE_ENV=production && cp app/index.html build/index.html && webpack"
},
In Windows, when you want to set Node env, you should do :
set NODE_ENV=production //in Mac
NODE_ENV=production
Copy the index.html to the build dir:
cp app/index.html build/index.html
Then run webpack, if u have installed the webpack globally, then just write:
webpack
webpack.config.js>
var webpack = require('webpack');
var config = {
context: __dirname + '/app',
entry: './index.js',
output: {
path: __dirname + '/app',
filename: 'bundle.js'
},
plugins: [
new webpack.DefinePlugin({
ON_TEST: process.env.NODE_ENV === "test"
})
],
module: {
loaders: [
{test: /\.js$/, loader: 'babel-loader', exclude: /node_modules/},
{test: /\.html$/, loader: 'html-loader', exclude: /node_modules/},
{test: /\.css$/, loader: 'style!css', exclude: /node_modules/},
{test: /\.styl/, loader: 'style!css!stylus', exclude: /node_modules/}
]
}
};
if(process.env.NODE_ENV === "production"){
config.output.path = __dirname + "/build"
}
module.exports = config;
[AngularJS + Webpack] Production Setup的更多相关文章
- [Webpack 2] Optimize React size and performance with Webpack production plugins
You can fine tune several webpack plugins to make your bundle as small as it can be for your specifi ...
- [AngularJS + Webpack] require directives
direictives/index.js: module.exports = function(ngModule) { //register all the directives here requi ...
- [AngularJS + Webpack] Using Webpack for angularjs
1. Install webpack & angular: npm install webpack angular 2. Create webpack.config.js file: modu ...
- [AngualrJS + Webpack] Production Source Maps
When you uglify your Angular code with Webpack's uglify plugin, debugging your application can be a ...
- [AngularJS + Webpack] Uglifying your JavaScript
Angular requires some careful consideration when uglifying your code because of how angular's depend ...
- [AngularJS + Webpack] Requiring Templates
With Angular, most of the time you're specifying a templateUrl for your directives and states/routes ...
- [AngularJS + Webpack] Requiring CSS & Preprocessors
Making your CSS modular is a difficult thing to do, but using Webpack makes this so much easier. By ...
- [AngularJS + Webpack] ES6 with BabelJS
Install: npm install --save-dev babel-loader webpack.config.js: Add module, tell webpack to find all ...
- 虽然今天angular5发布了,但我还是吧这篇angularjs(1)+webpack的文章发出来吧哈哈哈
本文为原创,转载请注明出处: cnzt 文章:cnzt-p http://www.cnblogs.com/zt-blog/p/7779384.html 写在前面: 因为最近总结自己之前做过 ...
随机推荐
- Android Linux自带iptables配置IP访问规则
利用Linux自带iptables配置IP访问规则,即可做到防火墙效果
- "_OBJC_CLASS_$_WeiboApi", referenced from: objc-class-ref in libtuyoo.a(TuYoo.o)
Undefined symbols for architecture i386: "_OBJC_CLASS_$_WeiboApi", referenced from: objc-c ...
- C语言头文件的使用与写法
C语言中的.h文件和我认识由来已久,其使用方法虽不十分复杂,但我却是经过了几个月的“不懂”时期,几年的“一知半解”时期才逐渐认识清楚他的本来面目.揪其原因,我的驽钝和好学而不求甚解固然是原因之一,但另 ...
- Delphi 记事本 TMemo(5篇)
模仿的很不错,在本质上与windows记事本使用了同一个Edit. http://www.cnblogs.com/xe2011/category/524758.htmlhttp://www.cnblo ...
- Drools引擎学习
首先上一段话: 为提高效率,管理流程必须自动化,即使现代商业规则异常复杂.市场要求业务规则经常变化,系统必须依据业务规则的变化快速.低成本的更新.为了快速.低成本的更新,业务人员应能直接管系统中的规则 ...
- Google Map API学习1
这一段时间公司一个新产品上线, 做超市代购的 这样,就需要计算每个门店也就是超市,距离小区之间的距离. 我们用的是Google Map 1.批量对地址进行编码,也就是将地址批量转化成对应的Goole ...
- php5.4下安装ECshop出现错误的解决办法
转:http://www.programmernote.com/?p=65 1.安装是会提示 Warning: date_default_timezone_get(): It is not safe ...
- activity+fragment多次切换出现页面空白问题
刚上手一个项目 懒的用viewpager+fragment模式,尽管在后面的项目中还是用到viewpager+fragment.先说说问题,多次切换fragment的时候页面出现空白,刚开始以为传递的 ...
- 数学(概率):HNOI2013 游走
[题目描述] 一个无向连通图,顶点从1编号到N,边从1编号到M. 小Z在该图上进行随机游走,初始时小Z在1号顶点,每一步小Z以相等的概率随机选 择当前顶点的某条边,沿着这条边走到下一个顶点,获得等于这 ...
- js弹框处理
# -*- coding:utf-8 -*- """ js弹框处理 """ from selenium import webdriver d ...