[Webpack 2] Intro to the Production Webpack Course
webpack to The intro production Course
2023-09-14 08:59:19 时间
There are several lessons that will build on top of this project. It is a fairly standard, small webpack bundled project. In this lesson we’ll explore the project a bit so you’re familiar with how things are set up for future lessons.
In Webpack 2, the config take a fucntion, which accept a env param points to system env.
const {resolve} = require('path') module.exports = env => { return { entry: './js/app.js', output: { filename: 'bundle.js', path: resolve(__dirname, 'dist'), pathinfo: !env.prod, }, context: resolve(__dirname, 'src'), devtool: env.prod ? 'source-map' : 'eval', bail: env.prod, module: { loaders: [ {test: /\.js$/, loader: 'babel!eslint', exclude: /node_modules/}, {test: /\.css$/, loader: 'style!css'}, ], }, } }
Package.json scripts:
"scripts": { "test": "karma start", "check-coverage": "istanbul check-coverage --statements 23 --branches 5 --functions 9 --lines 24", "watch:test": "npm test -- --auto-watch --no-single-run", "validate": "npm-run-all --parallel validate-webpack:* lint test --serial check-coverage", "validate-webpack:dev": "webpack-validator webpack.config.js --env.dev", "validate-webpack:prod": "webpack-validator webpack.config.js --env.prod", "clean-dist": "rimraf dist", "copy-files": "cpy src/index.html src/favicon.ico dist", "clean-and-copy": "npm run clean-dist && npm run copy-files", "prestart": "npm run clean-and-copy", "start": "webpack-dev-server --env.dev --content-base dist", "prebuild": "npm run clean-and-copy", "prebuild:prod": "npm run clean-and-copy", "build": "webpack --env.dev", "build:prod": "webpack --env.prod -p", "lint": "eslint .", "setup": "npm install && npm run validate" }
相关文章
- webpack基本配置项_webpack配置文件详解
- webpack配置文件_webpackconfig.js详解
- vue webpack 前后端请求响应流程
- 前端工程化与webpack
- webpack模块化
- webpack-notebook
- Webpack笔记
- webpack 初识配置文件
- Webpack提取页面公共资源
- 8-1. 「webpack源码分析」一个具体案例再次深入看buildChunkGraph的运行过程
- webpack 多页面配置
- webpack原理(1):Webpack热更新实现原理代码分析
- wxapp-boilerplate:使用 webpack, babel, scss 开发的微信小程序项目脚手架
- ORA-26748: The one-to-one transformation function string encountered the following error: string ORACLE 报错 故障修复 远程处理
- ORA-53410: The attribute string does not conform to the VM rule. ORACLE 报错 故障修复 远程处理
- 浅谈webpack优化详解编程语言
- webpack快速构建基于Koa2、MySQL和Webpack的Web应用(koa2mysql)
- Exploring the Power of MongoDB: The Definitive Guide to Upgrading Arrays(mongodb更新数组)
- 利用Oracle TO函数实现数据转换(oracle to_函数)