Open xiaodongxier opened 1 year ago
'use strict' const path = require('path'); function resolve(dir) { return path.join(__dirname, dir) }
module.exports = { indexPath: "index.html", devServer: {}, // ... configureWebpack: { resolve: { alias: { '@': resolve('src'), //本项目路径src路径设置别名为@ 'assets': resolve('src/assets'), //本项目路径src/assets路径设置别名为assets,静态文件前要加~,否则只会以当前目录为基准 '$s': path.resolve(dirname, '../static/'), //项目根路径同级static目录设置别名为$$ '$@': path.resolve(dirname, '../static/src/') //项目根路径同级static/src目录设置别名为$@ } } }, / //或者也可以这么配置 chainWebpack: config => { config.resolve.alias .set('@', resolve('src')) //本项目路径src路径设置别名为@ .set('assets', resolve('src/assets')) //本项目路径src/assets路径设置别名为assets,静态文件前要加~,否则只会以当前目录为基准 .set('$s', path.resolve(dirname, '../static/')) //项目根路径同级static目录设置别名为$$ .set('$@', path.resolve(dirname, '../static/src/')) //项目根路径同级static/src目录设置别名为$@ } / }
'use strict' const path = require('path'); function resolve(dir) { return path.join(__dirname, dir) }
module.exports = { indexPath: "index.html", devServer: {}, // ... configureWebpack: { resolve: { alias: { '@': resolve('src'), //本项目路径src路径设置别名为@ 'assets': resolve('src/assets'), //本项目路径src/assets路径设置别名为assets,静态文件前要加~,否则只会以当前目录为基准 '$s': path.resolve(dirname, '../static/'), //项目根路径同级static目录设置别名为$$ '$@': path.resolve(dirname, '../static/src/') //项目根路径同级static/src目录设置别名为$@ } } }, / //或者也可以这么配置 chainWebpack: config => { config.resolve.alias .set('@', resolve('src')) //本项目路径src路径设置别名为@ .set('assets', resolve('src/assets')) //本项目路径src/assets路径设置别名为assets,静态文件前要加~,否则只会以当前目录为基准 .set('$s', path.resolve(dirname, '../static/')) //项目根路径同级static目录设置别名为$$ .set('$@', path.resolve(dirname, '../static/src/')) //项目根路径同级static/src目录设置别名为$@ } / }