我尝试了许多解决方案,但没有发现任何可行的方法。
我所有文件的基本目录是localhost / manpower
我把它放到了我的webpack中... 让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();
当我将〜用作首页时,CSS的处理只会删除〜
mix.setPublicPath('manpower / public');
只需在现有文件结构下创建一个目录,然后将文件放入其中。不幸的是,这种流行的解决方案不会更改最终CSS的输出。
无论如何,我都无法在SCCS中添加URL来添加“ manpower”!
答案 0 :(得分:0)
发布我的配置来帮助您,我认为您忘了定义别名,我将配置放在两个文件中,以帮助IDE(PHPStorm)识别〜 (此答案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/'
}
})
答案 1 :(得分:0)
新版本
const path = require('path');
const mix = require('laravel-mix');
const webpack = require('webpack');
mix
.js('resources/assets/js/app.js', 'assets/js')
.sass('resources/assets/sass/app.scss', 'assets/css')
.sass('resources/assets/sass/header.scss', 'assets/css')
.version()
.options({
processCssUrls: true
});
if (mix.inProduction()) {
mix.version()
}
mix.webpackConfig({
resolve: {
alias: {
'~': path.join(__dirname, './resources/')
}
},
output: {
chunkFilename: 'dist/js/chunk.[name].[chunkhash].js',
path: process.env.MIX_APP_URL,
publicPath: '/public/'
}
})
答案 2 :(得分:0)
我很确定这是webpack.config.js的问题
我已经能够解决某些问题,但错误仍然存在。
/**
* As our first step, we'll pull in the user's webpack.mix.js
* file. Based on what the user requests in that file,
* a generic config object will be constructed for us.
*/
let mix = require('../index');
let ComponentFactory = require('../components/ComponentFactory');
new ComponentFactory().installAll();
require(Mix.paths.mix());
/**
* Just in case the user needs to hook into this point
* in the build process, we'll make an announcement.
*/
Mix.dispatch('init', Mix);
/**
* Now that we know which build tasks are required by the
* user, we can dynamically create a configuration object
* for Webpack. And that's all there is to it. Simple!
*/
let WebpackConfig = require('../src/builder/WebpackConfig');
//module.exports = new WebpackConfig().build();
const path = require('path')
const webpack = require('webpack')
module.exports = {
resolve: {
extensions: ['.js', '.json', '.vue'],
alias: {
'~': path.resolve(__dirname, './resources/assets/js')
},
},
output: {
path: process.env.MIX_APP_URL,
publicPath: '/manpower/public/',
chunkFilename: 'dist/js/chunk.[name].js'
}
}
答案 3 :(得分:0)
您可能想提供您的mix和sass-loader版本(旧的sass-loader中存在一个错误,该错误与tilde不兼容)。另外,请不要在更新时发表评论,否则会引起您的疑问。
通常,避免使用波浪号;而是使用相对路径。您想看一下这个答案:https://stackoverflow.com/a/33972875/2188545
即使没有所有令人困惑的注释,波浪号在url中使用时也会造成混乱,尤其是当您的浏览器路径manpower/
不是简单的根/
路径时。别误会,在CSS导入中使用tilde很好,因为在编译过程中通常可以解决该问题。在url
中使用时会更加混乱。另外,请在您的CSS网址周围使用引号。