G
G
GrimJack2017-07-17 13:50:30
Laravel
GrimJack, 2017-07-17 13:50:30

How to take folder content under laravel mix version control?

There is such a code for the collector (not written by me)

webpack.mix.js
let mix = require('laravel-mix');
const NAMESPACE_DESKTOP = 'assets/desktop/';
const NODE_ENV = process.env.NODE_ENV || 'production';
const WebpackNotifierPlugin = require('webpack-notifier');
const ExtractTextPlugin = require("extract-text-webpack-plugin");

const webpack = require('webpack');

mix.webpackConfig({
    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']
    }
});


It works fine.
I need to add version control from laravel mix for js and css files.
Since I'm new to webpack, I can't figure out where to add .version() and how. Because in the documentation everything is too simplistic
How will it be correct to add versions?
UPD
If you add mix.version();
{
    "/desktop.js": "/desktop.js",
    "/desktop.css": "/desktop.css",
    "/login.js": "/login.js",
    "/login.css": "/login.css"
}

And it should be together with the assets folder

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Pushkarev, 2017-07-17
@AXP-dev

Then mix.webpackConfig({});add mix.version();.
In general, it is better to add this to the end of the file:

if (mix.inProduction()) {
    mix.version();
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question