内容简介:最新版本的webpack已经可以不需要webpack.config.js作为配置文件。如果你的项目缺失配置文件的话,webpack会做以下默认配置:如果项目根目录有webpack.config.js文件,那webpack会默认使用它作为配置文件。我们也可以自己在命令行里通过 --config 指定配置文件,例如:webpakc使用node.js内置的path库来处理路径:
1: 默认entry和output
最新版本的webpack已经可以不需要webpack.config.js作为配置文件。如果你的项目缺失配置文件的话,webpack会做以下默认配置:
entry - src/index.js output - dist/main.js
2: 默认配置文件 vs 制定配置文件
如果项目根目录有webpack.config.js文件,那webpack会默认使用它作为配置文件。我们也可以自己在命令行里通过 --config 指定配置文件,例如:
"scripts": {
"build": "webpack --config prod.config.js"
}
3: path
webpakc使用node.js内置的path库来处理路径:
const path = require('path')
你可能还会注意到这个变量:__dirname
__dirname 的值就是当前module的路径,它和对__filename执行path.dirname()是一样的。例如:在/Users/mjr 路径下执行node example.js,那么:
console.log(__dirname); // Prints: /Users/mjr console.log(path.dirname(__filename)); // Prints: /Users/mjr
以上所述就是小编给大家介绍的《webpack配置基础》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!
猜你喜欢:本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
Algorithms on Strings, Trees and Sequences
Dan Gusfield / Cambridge University Press / 1997-5-28 / USD 99.99
String algorithms are a traditional area of study in computer science. In recent years their importance has grown dramatically with the huge increase of electronically stored text and of molecular seq......一起来看看 《Algorithms on Strings, Trees and Sequences》 这本书的介绍吧!