All Projects → deepred5 → webpack4-boilerplate

deepred5 / webpack4-boilerplate

Licence: other
webpack4打包模板

Programming Languages

javascript
184084 projects - #8 most used programming language
CSS
56736 projects
SCSS
7915 projects
HTML
75241 projects

Projects that are alternatives of or similar to webpack4-boilerplate

Vue Element Admin
🎉 A magical vue admin https://panjiachen.github.io/vue-element-admin
Stars: ✭ 73,044 (+202800%)
Mutual labels:  webpack4
webpack-playground
No description or website provided.
Stars: ✭ 16 (-55.56%)
Mutual labels:  webpack4
express-generator
Boilerplate | ExpressJS server
Stars: ✭ 35 (-2.78%)
Mutual labels:  bolierplate
next.js-boilerplate
next.js bolierplate, next.js 的开发模板
Stars: ✭ 28 (-22.22%)
Mutual labels:  bolierplate
eva
Évaluer en ligne les compétences transversales à travers des mises en situation professionnelles
Stars: ✭ 14 (-61.11%)
Mutual labels:  webpack4
eruda-webpack-plugin
A webpack plugin of eruda to help you develop mobile app
Stars: ✭ 56 (+55.56%)
Mutual labels:  webpack4
Wpk
a friendly, intuitive & intelligent CLI for webpack
Stars: ✭ 232 (+544.44%)
Mutual labels:  webpack4
Project06-A-Slack
팀 협업도구, 우리동네 슬랙 🚀
Stars: ✭ 14 (-61.11%)
Mutual labels:  webpack4
MyMina
小程序工程化实践
Stars: ✭ 73 (+102.78%)
Mutual labels:  webpack4
quickstart-miniprogram
🎉微信小程序webpack模板
Stars: ✭ 32 (-11.11%)
Mutual labels:  webpack4
react-native-basekit
Basic setup for react-native projects using react-native , redux, redux-sagas, react-navigation
Stars: ✭ 16 (-55.56%)
Mutual labels:  bolierplate
aurelia-dotnet-template
A starting point for new dotnet projects using the aurelia-framework with typescript and webpack.
Stars: ✭ 13 (-63.89%)
Mutual labels:  webpack4
webpack-boilerplate
Webpack 4 boilerplate (babel, eslint, prettier, jest, sass, postcss, hmr, browsersync)
Stars: ✭ 33 (-8.33%)
Mutual labels:  webpack4
go-api-boilerplate
Boilerplate for Golang API
Stars: ✭ 153 (+325%)
Mutual labels:  bolierplate
webpack-demos
webpack小练习
Stars: ✭ 17 (-52.78%)
Mutual labels:  webpack4
React Admin
动态菜单配置、权限精确到按钮、通用模块;标准后台管理系统解决方案
Stars: ✭ 247 (+586.11%)
Mutual labels:  webpack4
ultimate-hot-boilerplate
🚀 node-react universal app boilerplate with everything on hot reload, SSR, GraphQL, Flow included
Stars: ✭ 35 (-2.78%)
Mutual labels:  webpack4
bootpack
Create multi-page websites using bootstrap for development and webpack for task running.
Stars: ✭ 30 (-16.67%)
Mutual labels:  webpack4
boilerplate-react-redux-pwa
It's sample boilerplate with pwa + react + redux + redux-saga
Stars: ✭ 14 (-61.11%)
Mutual labels:  webpack4
Vi-Ui
💙 A simple but consistent user interface made for Vue
Stars: ✭ 42 (+16.67%)
Mutual labels:  webpack4

webpack4-boilerplate

webpack4 多页面打包模板

  • 支持React
  • 支持scss, autoprefixer自动加浏览器前缀, icon字体图标
  • ES6+语法 babel编译成 ES5语法
  • 提取公共css和js,自动添加版本号
  • 打包压缩js和css
  • Mock数据 接口转发

使用

安装

npm install

开发(默认开启本地mock)

npm run dev

预览: http://localhost:9001/trade-index

关闭mock

npm run dev:no-mock

接口代理(关闭本地mock,开启远程代理,用于后端联调)

npm run proxy

打包

npm run build

自定义打包目录

npm run dev:custom

开发阶段,如果page目录下页面过多,会导致打包缓慢,影响开发效率。可以新建一个customPages.json指定开发阶段需要打包的页面

{
  "pages": [
    "trade-index",
    "trade-success"
  ]
}

说明


pages目录下,每个文件夹为单独的一个页面

每个页面至少有两个文件配置:

app.js: 页面的逻辑入口

index.html: 页面的html打包模板


assets目录下,放静态资源,比如图片资源


styles目录下,放公共全局的css


可以自行添加文件夹,比如全局的components公共组件, utils全局工具方法


mock目录为本地mock数据,文档详见mocker-api


build目录为webpack打包配置,有详细的注解

代码分割使用的是splitChunks配置

optimization: {
    splitChunks: {
      cacheGroups: {
        // 打包业务中公共代码
        common: {
          name: "common",
          chunks: "initial",
          minSize: 1,
          priority: 0,
          minChunks: 3, // 同时引用了3次才打包
        },
        // 打包node_modules中的文件
        vendor: {
          name: "vendor",
          test: /[\\/]node_modules[\\/]/,
          chunks: "initial",
          priority: 10,
          minChunks: 2, // 同时引用了2次才打包
        }
      }
    }
  }

接口代理详见devServerProxy.js

const proxy = {
  '/api': {
    target: 'https://anata.me', // 后端地址
    changeOrigin: true,
    secure: false,
  },
}

其他

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].