分享web开发知识

注册/登录|最近发布|今日推荐

主页 IT知识网页技术软件开发前端开发代码编程运营维护技术分享教程案例
当前位置:首页 > 教程案例

webacp4.0

发布时间:2023-09-06 01:46责任编辑:赖小花关键词:暂无标签

‘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

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

知识推荐

我的编程学习网——分享web前端后端开发技术知识。 垃圾信息处理邮箱 tousu563@163.com 网站地图
icp备案号 闽ICP备2023006418号-8 不良信息举报平台 互联网安全管理备案 Copyright 2023 www.wodecom.cn All Rights Reserved