const path = require('path'); module.exports = { // devServer:{ // proxy: { // '/api': { // target: 'https://test.yishaxiyi.com', // changeOrigin: true, // ws: true, // pathRewrite: { // '^/api': '' // } // } // } // }, // pubilcPath:'./', // assetsDir:'./src/static', configureWebpack:(config)=>{ }, chainWebpack: (config) => { /** * 导入全局css * @type {*[]} */ const types = ['vue-modules', 'vue', 'normal-modules', 'normal']; types.forEach(type => addStyleResource(config.module.rule('stylus').oneOf(type))); /** * 配置路径别名,项目中引用资源的时候路径可以更简短 * 但是ts文件在用的时候,编译器会报错,需要添加 @ts-ignore * 忽略开发工具的错误。 */ config.resolve.alias .set('@static', resolve('src/static')) .set('@stylus', resolve('src/view/assets/stylus')) .set('@components', resolve('src/view/components')); } } function resolve(dir) { return path.join(__dirname, dir); } function addStyleResource(rule) { rule.use('style-resource') .loader('style-resources-loader') .options({ patterns: [ path.resolve(__dirname, './src/view/assets/stylus/imports.styl') ], }); }