G
G
GrimJack2017-07-13 18:34:59
webpack
GrimJack, 2017-07-13 18:34:59

Is it possible to somehow interfere with the webpack build by adding laravel mix .version?

There is such webmack.config.js

webpack
const NAMESPACE_DESKTOP = 'assets/desktop/';
const NODE_ENV = process.env.NODE_ENV || 'development';

const webpack = require('webpack');

const WebpackNotifierPlugin = require('webpack-notifier');
const ExtractTextPlugin = require("extract-text-webpack-plugin");

module.exports = {
    context: __dirname + '/resources/assets',
    entry: {
        desktop: './desktop',
        login: './login'
    },
    output: {
        path: __dirname + '/public/assets',
        filename: "[name].js",
        library: '[name]'
    },
    devtool: 'cheap-inline-module-source-map',
    module: {
        loaders: [
            {
                test: /\.js$/,
                exclude: /(node_modules)/,
                loaders: ['ng-annotate', 'babel?presets[]=es2015']
            },
            {
                test: /\.css$/,
                loader: ExtractTextPlugin.extract('style', 'css!resolve-url')
            },
            {
                test: /\.less$/,
                loader: ExtractTextPlugin.extract('style', 'css!resolve-url!less')
            },
            {
                test: /\.scss$/,
                loader: ExtractTextPlugin.extract('style', 'css!resolve-url!sass?sourceMap')
            },
            {
                test: /\.(jpe?g|png|gif|otf|eot|svg|ttf|woff|html)/,
                loader: 'file?name=[path][name].[ext]'
            }
            //{
            //    test: /\.woff($|\?)|\.woff2($|\?)|\.ttf($|\?)|\.eot($|\?)|\.svg($|\?)/,
            //    loader: 'url-loader'
            //}
        ],
        noParse: ['node_modules']
    },
    plugins: [
        new webpack.ProvidePlugin({
            $: "jquery",
            jQuery: "jquery",
            "window.jQuery": "jquery",
            _: "underscore",
            "window._": "underscore"
        }),
        new webpack.NoErrorsPlugin(),
        new WebpackNotifierPlugin({title: 'Webpack'}),
        new webpack.DefinePlugin({
            NAMESPACE_DESKTOP: JSON.stringify(NAMESPACE_DESKTOP),
            NODE_ENV: JSON.stringify(NODE_ENV)
        }),
        new webpack.HotModuleReplacementPlugin(),
        new ExtractTextPlugin('[name].css', {allChunks: true})
    ],
    resolve: {
        extensions: ['', '.js', '.html', '.less', '.scss', '.css']
    },
    watch: NODE_ENV == 'development',
    watchOptions: {
        aggregateTimeout: 100
    },
    devServer: {
        host: 'localhost',
        port: '8080',
        contentBase: __dirname + '/public',
        hot: false,
        inline: false,
        publicPath: '/assets',
        headers: {
            'Access-Control-Allow-Origin': '*'
        }
    }
};

if (NODE_ENV != 'development') {
    module.exports.plugins.push(
        new webpack.optimize.UglifyJsPlugin({
            compress: {
                warnings: false,
                drop_console: false,
                unsafe: true
            }
        })
    );

}


It is necessary that when npm run prod(NODE_ENV=production webpack ) the final css and js files go through mix.****.version();
But there's a problem. Before that, I had never worked with webpack and in general js was at the jquery level, so it’s hard for me to understand what’s going on there, and now I don’t have time for it.
I understand that at the beginning of the code you need to add let mix = require('laravel-mix');
And here's how and what to wrap next so that the same mix.****.version(); I don't understand. Please put me on the right path.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question