dongre6404 2018-12-10 18:00
浏览 291

Laravel home(〜)SCSS路径无法正确解析

Ive tried a number of solutions and have not found anything that works.

My base directory for all files is localhost/manpower

I put this in my webpack... let mix = require('laravel-mix');

/*
 |--------------------------------------------------------------------------
 | Mix Asset Management
 |--------------------------------------------------------------------------
 |
 | Mix provides a clean, fluent API for defining some Webpack build steps
 | for your Laravel application. By default, we are compiling the Sass
 | file for the application as well as bundling up all the JS files.
|
 */
mix.js('resources/assets/js/app.js', 'public/assets/js')
    .sass('resources/assets/sass/app.scss', 'public/assets/css')
    .sass('resources/assets/sass/header.scss', 'public/assets/css')
    .version();

When I use the ~ for the home, the processing of the CSS just removes the ~

mix.setPublicPath('manpower/public');

Just creates a directory under the existing file structure and puts the files in that. Unfortunately this popular solution does not change the output of the final CSS.

No mater what I try, I can't get it to add 'manpower' to the URL's I put in the SCCS!

  • 写回答

4条回答

  • douyouqian8550 2018-12-10 18:31
    关注

    Posting my config to help you, I think that you forgot to define the alias, I have my config in two files to help the IDE (PHPStorm) recognize the ~ (solution from this answer https://stackoverflow.com/a/50159420/5458355)

    // webpack.config.js

    const path = require('path')
    const webpack = require('webpack')
    const LodashModuleReplacementPlugin = require('lodash-webpack-plugin')
    
    module.exports = {
    
    resolve: {
      extensions: ['.js', '.json', '.vue'],
      alias: {
        '~': path.resolve(__dirname, './resources/assets/js')
      }
    },
    output: {
      path: process.env.MIX_APP_URL, <--- var from .env
      publicPath: '/Socse.GST/public/',
      chunkFilename: 'dist/js/chunk.[name].js'
     } 
    }
    

    // webpack.mix.js

    const path = require('path')
    const mix = require('laravel-mix')
    const webpack = require('webpack')
    
    mix
     .js('resources/assets/js/app.js', 'public/dist/js')
     .sass('resources/assets/sass/app.scss', 'public/dist/css')
     .styles([
       'resources/assets/sass/fa/css/fontawesome-all.css',
       'public/css/awesome-bootstrap-checkbox.css',
       'public/css/inspinia.css',
       'node_modules/vue-multiselect/dist/vue-multiselect.min.css'
     ], 'public/dist/css/all.css')
    
     .sourceMaps()
     //.disableNotifications()
    
    if (mix.inProduction()) {
      mix.version()
    }
    
    mix.webpackConfig({
      plugins: [
        new webpack.ProvidePlugin({
         $: 'jquery',
         jQuery: 'jquery',
         'window.jQuery': 'jquery',
         Popper: ['popper.js', 'default']
      })
    ],
    resolve: {
        extensions: ['.js', '.json', '.vue'],
          alias: {
           '~': path.join(__dirname, './resources/assets/js')
          }
        },
    output: {
       chunkFilename: 'dist/js/chunk.[name].[chunkhash].js',
       path: process.env.MIX_APP_URL,
       publicPath: '/wms/public/'
      }
    })
    
    评论

报告相同问题?

悬赏问题

  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记