webpack - 尝试不止一次加载角度

时间:2016-11-18 07:07:58

标签: javascript angularjs webpack

下面是我的ng应用程序中的webpack配置文件。我正在使用vendor.which加载所有库,两次编译捆绑包 dev-server.js正在加载两次热编译

这是我在webpack.config.js中的代码

   var webpack = require('webpack'),
   path = require("path"),
   ExtractTextPlugin = require('extract-text-webpack-plugin'),
   HtmlWebpackPlugin = require('html-webpack-plugin');

   var node_dir = path.join(__dirname + '/node_modules');
  var lib_dir = path.join(__dirname + '/app/libs');


var config = {
  context:path.join( __dirname,'app'),  
 entry:  {
  app:[
    "webpack-dev-server/client?http://localhost:8080",
    "webpack/hot/only-dev-server",
    "./index.js"
  ],
  vendors: ['jquery','angular','angular-ui-bootstrap','angular-ui-router','oclazyload']//,'c.clipboard'
 },
output:{
path:__dirname + "/app", 
filename:"./bundle.js",
publicPath: "http://localhost:8080/"  
},
watch:true,
devtool: 'source-map',
resolve:{
 alias:{jquery: "jquery/src/jquery"},
 extensions:['','.js','.css','.less','.html']
},
module:{
 noParse: [ /[\/\\]node_modules[\/\\]angular[\/\\]angular\.js$/],
 loaders:[
  {
  test: /\.js$/,       
  loader: 'babel-loader',
  query: {
    presets: ["es2015"], 
    compact: false 
  },
  exclude: '/node_modules/'
  },  
  {
    test: /\.less$/,
    loader:ExtractTextPlugin.extract(['css','less'])        
  },   
  { 
    test: /\.css$/,
    loader:ExtractTextPlugin.extract(['css'])
  },
  //{test: /\.less$/, loader: 'style-loader!css-loader!less-loader'},
  //{test: /\.css$/, loader: 'style-loader!css-loader'},
  //{test: /bootstrap\/js\//, loader: 'imports?jQuery=jquery' }, 
  {test: /\.(png|woff|woff2|eot|ttf|svg)$/, loader: 'url-loader?limit=100000' },
  {test: /\.woff(2)?(\?v=[0-9]\.[0-9]\.[0-9])?$/, loader: "url-loader?limit=10000&minetype=application/font-woff" },
  {test: /\.(ttf|eot|svg)(\?v=[0-9]\.[0-9]\.[0-9])?$/, loader: "file-loader" },
  {test: /[\/\\]node_modules[\/\\]some-module[\/\\]index\.js$/,loader: "imports?this=>window"}   
]
}, 
plugins: [
//new webpack.ProvidePlugin({$: "jquery",jQuery: "jquery"}),
new webpack.HotModuleReplacementPlugin(),
new webpack.NoErrorsPlugin(),
new webpack.optimize.DedupePlugin(),
new ExtractTextPlugin('style.css', { allChunks: true }),  
new webpack.optimize.CommonsChunkPlugin('vendors', 'vendor.js',Infinity),
new HtmlWebpackPlugin({template:'./index.html',inject: false})    

],
devServer:{
inline:true,
stats:'erros',
 hot: true,
port:8080
},
debug: true
};
module.exports = config; 

0 个答案:

没有答案