How do we extract CSS chunks file in Laravel with Vue?

余生长醉 提交于 2019-12-12 01:25:29

问题


I am working in Laravel with Vue.js and in my webpack.config.js file I am extracting the js chunks file like this:

mix.webpackConfig({
    resolve: {
        alias: {...
            'Helpers': path.resolve(__dirname, 'resources/js/helpers/'),
            'Themes': path.resolve(__dirname, 'resources/js/themes/')
        ...}
    },
    output: {
        chunkFilename: 'js/chunks/[name].js',
    },
});

This extract the js chunks file like 0.js , 1.js ,2.js etc. I want to extract the CSS chunks in same way.


回答1:


I was having the same problem with vuely xd. For now what I have done this:

mix.autoload({
    'jquery': ['$', 'window.jQuery', 'jQuery'],
})

mix.webpackConfig({
    resolve: {
        alias: {
            'Api': path.resolve(__dirname, 'resources/js/api/'),
            'Components': path.resolve(__dirname, 'resources/js/components/'),
            'Constants': path.resolve(__dirname, 'resources/js/constants/'),
            'Container': path.resolve(__dirname, 'resources/js/container/'),
            'Views': path.resolve(__dirname, 'resources/js/views/'),
            'Helpers': path.resolve(__dirname, 'resources/js/helpers/'),
            'Themes': path.resolve(__dirname, 'resources/js/themes/')
        }
    },
    output: {
        chunkFilename: mix.inProduction() ? "js/chunks/[name].[chunkhash].js" : "js/chunks/[name].js",
    }
});


mix.options({
    extractVueStyles: true
});

mix.js('resources/js/main.js', 'public/js');
mix.sass('resources/js/assets/scss/_style.scss', 'public/css/style.css');


来源:https://stackoverflow.com/questions/54234817/how-do-we-extract-css-chunks-file-in-laravel-with-vue

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!