JeffreyWay / laravel-elixir-webpack-official

88 stars 28 forks source link

Production flag has no effect #58

Open mityukov opened 6 years ago

mityukov commented 6 years ago

Just noticed (quite recently…) that issuing gulp --production does not "clean up" my javascript files anymore.

It does minification. But I get console.logs and "Vue is in dev mode" warning when I open Development tools…

// package.json
{
  "private": true,
  "scripts": {
    "prod": "gulp --production",
    "dev": "gulp watch",
    "build": "gulp"
  },
  "devDependencies": {
    "bootstrap-sass": "^3.3.7",
    "del": "^2.2.2",
    "eslint": "^4.12.1",
    "eslint-config-standard": "^10.2.1",
    "eslint-plugin-promise": "^3.6.0",
    "eslint-plugin-standard": "^3.0.1",
    "eslint-plugin-vue": "^4.0.0-beta.2",
    "gentelella": "^1.3.0",
    "gulp": "^3.9.1",
    "jquery": "^3.2.1",
    "laravel-echo": "^1.3.0",
    "laravel-elixir": "^6.0.0-15",
    "laravel-elixir-vue-2": "^0.3.0",
    "laravel-elixir-webpack-official": "^1.0.10",
    "laravel-elixir-webpack-react": "^1.0.1",
    "laravel-vue-pagination": "^1.2.0",
    "lodash": "^4.17.4",
    "moment": "^2.18.1",
    "portal-vue": "^1.3.0",
    "pusher-js": "^4.1.0",
    "vue": "^2.4.1",
    "vue-resource": "^1.3.4",
    "vuedraggable": "^2.14.1"
  },
  "dependencies": {}
}
// gulpfile.js

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

require('laravel-elixir-vue-2');

require('laravel-elixir-webpack-react');

/**
 * @see https://joecurran.codes/blog/remove_files_with_elixir
 */
const del = require('del');
elixir.extend('delete', function (path) {
    new elixir.Task('delete', function () {
        del(path);
    });
});

elixir(mix => {
    mix.sass('app.scss');

    mix.webpack('app.js');

    mix.delete([
      'public/build/rev-manifest.json',
      'public/build/js',
      'public/build/css'
    ]);

    if (elixir.config.production) { // This, by the way, works; So, it's not gulp failing…
      mix.version([
        'js/app.js',
        'css/app.css'
      ]);
    }
});
// resources/assets/js/app.js

require('./bootstrap');

if (location.hostname.indexOf('my-production.url') === -1) {
    Vue.config.debug = true;
} else {
    Vue.config.devtools = false;
    Vue.config.debug = false;
    Vue.config.silent = true;
}