Created
April 29, 2019 04:05
-
-
Save sithuaung/130bbbc94b11a6ed3a54fa67f18b42b7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let mix = require('laravel-mix'); | |
/* | |
|-------------------------------------------------------------------------- | |
| Mix Asset Management | |
|-------------------------------------------------------------------------- | |
| | |
| Mix provides a clean, fluent API for defining some Webpack build steps | |
| for your Laravel application. By default, we are compiling the Sass | |
| file for the application as well as bundling up all the JS files. | |
| | |
*/ | |
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/') | |
} | |
} | |
}); | |
mix.js('resources/js/main.js', 'public/js') | |
.extract(); | |
if (mix.inProduction()) { | |
mix.webpackConfig({ | |
output: { | |
filename:'[name].js', | |
chunkFilename: '[name].[chunkhash].js', | |
} | |
}); | |
mix.version() | |
.then(stats => { | |
let manifest = Mix.manifest.read(); | |
let newManifest = {}; | |
Object.keys(manifest).map(function (item, index, input) { | |
let newKey = item.replace(/(vendor|main)(\.\S+)?(\.(\S+))/, '$1$3'); | |
newManifest[newKey] = manifest[item]; | |
}); | |
Mix.manifest.manifest = newManifest; | |
Mix.manifest.refresh(); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment