前端投屏pc/h5
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

64 lines
1.6 KiB

5 years ago
5 years ago
5 years ago
  1. const path = require('path')
  2. const resolve = file => path.resolve(__dirname, file)
  3. const pxtorem = require('postcss-pxtorem');
  4. const webpack = require('webpack') //JQ
  5. const isUrl = false;
  6. let baseURL;
  7. if (isUrl) {
  8. //正式站
  9. baseURL = 'http://api.zhdespi.com';
  10. } else {
  11. //测试站
  12. baseURL = 'http://119.28.9.35';
  13. }
  14. module.exports = {
  15. lintOnSave: false,
  16. publicPath: './', //HBuilder打包出现空白决解方案
  17. productionSourceMap: false,//是否生成.map文件.map文件的作用是帮助编译后的代码调试,但是我们上线的代码已经调试完成,所以上线时可以不生成.map文件
  18. //解决跨域
  19. devServer: {
  20. //port: 8081,// 端口号
  21. //open: true, //配置自动启动浏览器
  22. proxy: {
  23. //测试站
  24. '/api': {
  25. target: baseURL, //对应自己的接口
  26. changeOrigin: true,
  27. ws: true,
  28. pathRewrite: {
  29. '^/api': ''
  30. }
  31. },
  32. }
  33. },
  34. chainWebpack: config => {
  35. config.module
  36. .rule('md-postcss') // 新增规则,规则名自定义
  37. .test(/mand-mobile.*\.css$/) // 用正则表达式匹配mand-mobile的组件目录下的所有css文件
  38. .use('css-loader') // css加载器
  39. .loader('postcss-loader') // css处理器
  40. .options({ // 这里的内容跟方法一中css.loaderOptions一样
  41. plugins: [
  42. pxtorem({
  43. rootValue: 55,
  44. minPixelValue: 2,
  45. propList: ['*'],
  46. selectorBlackList: []
  47. })
  48. ]
  49. });
  50. },
  51. //引入JQ
  52. configureWebpack: {
  53. plugins: [
  54. new webpack.ProvidePlugin({
  55. $: "jquery",
  56. jQuery: "jquery",
  57. jquery: "jquery",
  58. "windows.jQuery": "jquery"
  59. })
  60. ]
  61. }
  62. }