webacp4.0
'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;
}();
最新文章
- .NET 的 Debug 和 Release build 对执行速度的影响
- JS详细教程(下)
- 怎么利用javascript删除字符串中的最后一个字符呢?
- Zookeeper-Zookeeper leader选举
- js模拟手机触摸屏
- 关于如何用php 获取当前脚本的url
- CentOS 6.x安装配置
- mysql 交叉表
- 对<;<; ubuntu 12.04编译安装linux-3.6.10内核笔记>;>;的修正
- 算法 - 求和为n的连续正整数序列(C++)
- Java开发常用下载的网址
- SqlServer拆分列
- 分解机(Factorization Machines)推荐算法原理
- python之optparse模块
- vpn服务器搭建
- ElfJS从入门到精通(一)
- [ExtJS5学习笔记]第四节 欢迎来到extjs5-手把手教你实现你的第一个应用
- Vue + WebApi 小项目:构造自己的在线 Markdown 笔记本应用
- formValidator 插件 使用总结
- JS之iscroll.js的使用详解
热门文章
- 从1<;2<;3的语法糖说起
- WriteDataToFile(filename,pJsonData,strlen(pJsonData)+1)
- Kotlin——关于字符串(String)常用操作汇总
- springboot+jsp项目实例(第二弹)(成功)
- Python基础教程(019)--执行Python的方式,IPython
- 微信小程序相关操作
- C# webbrowser专题
- JAVA(JDK,JRE)更改目录安装及环境变量配置
- BZOJ 5296: [Cqoi2018]破解D-H协议(BSGS)
- 后端技术杂谈4:Elasticsearch与solr入门实践