码迷,mamicode.com
首页 > Web开发 > 详细

webacp4.0

时间:2018-03-25 18:15:42      阅读:217      评论:0      收藏:0      [点我收藏+]

标签:clean   acp   touch   ===   serve   ports   services   source   pat   

‘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;
}();

 

webacp4.0

标签:clean   acp   touch   ===   serve   ports   services   source   pat   

原文地址:https://www.cnblogs.com/qiqi105/p/8645461.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!