UNPKG

kef-builder-buffet

Version:

buffet-builder构建工具

33 lines (25 loc) 947 B
/** * webpack 中 resolve 参数定义 * @param {json} config - webpack配置文件 */ 'use strict'; const path = require('path'); module.exports = function (config) { config.resolve = config.resolve || {}; // 添加JSX的自动解析 // 自动解析确定的扩展。默认值为:['.js', '.json'] config.resolve.extensions = ['*', '.js', '.jsx']; // 创建 import 或 require 的别名 // 这里common可以通过别名的方式来引用(需讨论) config.resolve.alias = { }; // 热启动必须要配置这个 config.resolve.modules = ['node_modules', path.resolve(__dirname, '../../', 'node_modules')]; // webpack 默认是从 cwd 的 node_mudles 中获取 loader。由于构建脚本是独立存在的,与业务仓库分离,需要指定 config.resolveLoader = { modules: [ // path.resolve(__dirname, '../../', 'node_modules') path.join(__dirname, '../../node_modules') ] }; };