'use strict';
const path = require('path');

var APP_PATH = path.resolve(__dirname, 'src');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const CleanWebpackPlugin = require('clean-webpack-plugin');

// const autoprefixer = require('autoprefixer');

const ENV = process.env.npm_lifecycle_event;
const isProd = ENV === 'build';

module.exports = function () {
const config = {

mode:'development',
devtool : 'module-source-map',

context: path.resolve(__dirname, 'src'),

entry: {
'app': path.resolve(APP_PATH ,'index.js'),
//
// 'vendor': [
// 'angular',
// '@uirouter/angularjs',
// // 'angular-resource',
// // 'mobile-angular-ui',
// // 'ng-dialog',
// // 'ngtouch',
// // 'angular-ui-utils',
// // 'moment',
// // 'baidumap',
//
// ]
},
output: {
path: path.resolve(__dirname,'dist'),
publicPath: '/',
filename: isProd ? '[name].[hash:8].js' : '[name].bundle.js',
chunkFilename: isProd ? '[name].[hash:8].js' : '[name].bundle.js'
},
module: {

rules: [
{
test: /\.js$/,
exclude: '/node_modules/',
use: {
loader: 'babel-loader'
}
},

{
test: /\.css$/,
use: ['style-loader', 'css-loader']
},

{test: /\.html$/, loader: 'raw-loader'},

{
test: /\.(png|jpg|gif)$/,
use: [
{
loader: 'url-loader',
options: {
limit: 8192
}
}
]
}

]

},
optimization: {
runtimeChunk: {
name: "manifest"
},
splitChunks: {
cacheGroups: {
commons: {
test: /[\\/]node_modules[\\/]/,
name: "vendor",
chunks: "all"
}
}
},
},

plugins: [

new HtmlWebpackPlugin({
template: path.resolve( APP_PATH, 'index2.html'),
//inject : 'body',
chunks: ['commons.chunk', 'vendor', 'app'],
chunksSortMode: 'dependency'
}),
new CleanWebpackPlugin(['dist']),

],

devServer: {
contentBase: 'src',
historyApiFallback: true,
port: 7070
},
resolve: {
alias: {
_components: path.resolve(APP_PATH, 'components'),
_config: path.resolve(APP_PATH, 'config'),
_assets: path.resolve(APP_PATH, 'assets'),
_pages: path.resolve(APP_PATH, 'pages'),
_services: path.resolve(APP_PATH, 'services')
}
}
};

return config;
}();

最新文章

  1. .NET 的 Debug 和 Release build 对执行速度的影响
  2. JS详细教程(下)
  3. 怎么利用javascript删除字符串中的最后一个字符呢?
  4. Zookeeper-Zookeeper leader选举
  5. js模拟手机触摸屏
  6. 关于如何用php 获取当前脚本的url
  7. CentOS 6.x安装配置
  8. mysql 交叉表
  9. 对<< ubuntu 12.04编译安装linux-3.6.10内核笔记>>的修正
  10. 算法 - 求和为n的连续正整数序列(C++)
  11. Java开发常用下载的网址
  12. SqlServer拆分列
  13. 分解机(Factorization Machines)推荐算法原理
  14. python之optparse模块
  15. vpn服务器搭建
  16. ElfJS从入门到精通(一)
  17. [ExtJS5学习笔记]第四节 欢迎来到extjs5-手把手教你实现你的第一个应用
  18. Vue + WebApi 小项目:构造自己的在线 Markdown 笔记本应用
  19. formValidator 插件 使用总结
  20. JS之iscroll.js的使用详解

热门文章

  1. 从1<2<3的语法糖说起
  2. WriteDataToFile(filename,pJsonData,strlen(pJsonData)+1)
  3. Kotlin——关于字符串(String)常用操作汇总
  4. springboot+jsp项目实例(第二弹)(成功)
  5. Python基础教程(019)--执行Python的方式,IPython
  6. 微信小程序相关操作
  7. C# webbrowser专题
  8. JAVA(JDK,JRE)更改目录安装及环境变量配置
  9. BZOJ 5296: [Cqoi2018]破解D-H协议(BSGS)
  10. 后端技术杂谈4:Elasticsearch与solr入门实践