首页 > Web开发 > 详细

[AngularJS + Webpack] Using Webpack for angularjs

时间:2015-04-13 06:50:19      阅读:264      评论:0      收藏:0      [点我收藏+]

1. Install webpack & angular:

npm install webpack angular

 

2. Create webpack.config.js file:

module.exports = {
    context: __dirname + ‘/app‘,
    entry: ‘./app.js‘,
    output: {
        path: __dirname + ‘/build‘,
        filename: ‘bundle.js‘
    }
}

The context is: app folder

The entry file is: app.js

The output: path is build folder and filename is bundle.js.

技术分享

 

3. app.js:

var anuglar = require(‘angular‘);
var ngModule = angular.module(‘app‘, []);

console.log(ngModule);

 

4. index.js:

<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title>Webpack + AngularJS</title>
</head>
<body ng-app="app">

</body>
<script src="../build/bundle.js"></script>
</html>

 

5. run webpack:

webpack -watch

 

6. In the web broswer console, you will see the ngModule object.

技术分享

 

[AngularJS + Webpack] Using Webpack for angularjs

原文:http://www.cnblogs.com/Answer1215/p/4421182.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!