laravel-elixir-webpack-official icon indicating copy to clipboard operation
laravel-elixir-webpack-official copied to clipboard

webpack code splitting: base app.js is only built with gulp --production

Open tripper54 opened this issue 8 years ago • 4 comments

I'm having trouble getting split js files to compile correctly. Everything works OK when I run gulp --production , but when I run gulp without --production , the base app.js is not compiled. The split modules are compiled OK to 0.app.js , 1.app.js etc . But the base app.js is simply missing.

My gulpfile:

const elixir = require('laravel-elixir');

require('laravel-elixir-vue');

var webpack = require('webpack');


elixir(mix => {
    mix.sass('app.scss')
        .webpack('app.js', 'public/js');
    mix.version('css/app.css');
});

Elixir.webpack.mergeConfig({
    module: {
        loaders: [
            {
                test: /\.svg$/,
                loader: 'file',
            },
            {
                test: /\.js$/,
                loader: 'babel',
                exclude: /node_modules/
            },
        ],
    },
    output: {publicPath: "/js/", filename: "app.js"},
    resolve: {
        alias: {
            vue: 'vue/dist/vue.js'
        }
    },

});

Does anyone have any idea what's up with this?

tripper54 avatar Nov 02 '16 00:11 tripper54

I'm having the exact same issue, any clues so far? I tried running webpack directly and it generated the all the files correctly, so the issue is probably not webpack-specific.

nicoit avatar Dec 09 '16 18:12 nicoit

No, I'm still stuck running --production every time I need to compile. I'll post back here if I come up with anything.

tripper54 avatar Dec 11 '16 02:12 tripper54

@tripper54 , thanks, you solved my issue of app.js trying to look for 0.app.js file in localhost/ rather than localhost/js output: {publicPath: "/js/", filename: "app.js"}, This line specifically!

ManasN avatar Dec 24 '16 11:12 ManasN

@tripper54 , I found that after upgrading nodejs to 6 and reinstalling all the modules everything went back to working as a charm on 2 different environments. I had by dev environments built long time ago and I overlooked this detail, I had node 5.6 for some reason. Hope this helps

nicoit avatar Jan 04 '17 05:01 nicoit