Skip to content

Commit 91cf735

Browse files
committed
Fix webpack compliation for prod, chunk out massive files for perf
1 parent cc6d10d commit 91cf735

File tree

2 files changed

+38
-4
lines changed

2 files changed

+38
-4
lines changed

resources/themes/pterodactyl/templates/wrapper.blade.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@
4242
@show
4343
@section('scripts')
4444
{!! $asset->js('main.js') !!}
45+
{!! $asset->js('vue.js') !!}
46+
{!! $asset->js('vendor.js') !!}
47+
{!! $asset->js('locales.js') !!}
4548
@show
4649
</body>
4750
</html>

webpack.config.js

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ let plugins = [
2121
'php artisan ziggy:generate resources/assets/scripts/helpers/ziggy.js',
2222
],
2323
}),
24-
new MiniCssExtractPlugin({ filename: 'bundle.[hash:8].css' }),
24+
new MiniCssExtractPlugin({ filename: isProduction ? 'bundle.[chunkhash:8].css' : 'bundle.[hash:8].css' }),
2525
new AssetsManifestPlugin({
2626
writeToDisk: true,
2727
publicPath: true,
@@ -50,7 +50,7 @@ if (isProduction) {
5050
return content.match(/[A-z0-9-:\/]+/g) || [];
5151
}
5252
},
53-
extensions: ['html', 'js', 'php', 'vue'],
53+
extensions: ['html', 'ts', 'js', 'php', 'vue'],
5454
},
5555
],
5656
}),
@@ -114,8 +114,8 @@ module.exports = {
114114
entry: ['./resources/assets/styles/main.css', './resources/assets/scripts/app.ts'],
115115
output: {
116116
path: path.resolve(__dirname, 'public/assets'),
117-
filename: 'bundle.[hash:8].js',
118-
chunkFilename: 'chunk.[name].js',
117+
filename: isProduction ? 'bundle.[chunkhash:8].js' : 'bundle.[hash:8].js',
118+
chunkFilename: isProduction ? '[name].[chunkhash:8].js' : '[name].[hash:8].js',
119119
publicPath: _.get(process.env, 'PUBLIC_PATH', '') + '/assets/',
120120
crossOriginLoading: 'anonymous',
121121
},
@@ -125,6 +125,18 @@ module.exports = {
125125
test: /\.vue$/,
126126
loader: 'vue-loader',
127127
},
128+
{
129+
test: /\.js$/,
130+
loader: 'babel-loader',
131+
options: {
132+
cacheDirectory: !isProduction,
133+
presets: ['@babel/preset-env'],
134+
plugins: [
135+
'@babel/plugin-proposal-class-properties',
136+
['@babel/plugin-proposal-object-rest-spread', { 'useBuiltIns': true }]
137+
],
138+
},
139+
},
128140
{
129141
test: /\.ts$/,
130142
exclude: /node_modules/,
@@ -167,6 +179,25 @@ module.exports = {
167179
},
168180
}),
169181
],
182+
splitChunks: {
183+
cacheGroups: {
184+
vue: {
185+
test: /[\\/]node_modules[\\/](vue\w?)[\\/]/,
186+
name: 'vue',
187+
chunks: 'initial',
188+
},
189+
locales: {
190+
test: /locales/,
191+
name: 'locales',
192+
chunks: 'initial',
193+
},
194+
vendors: {
195+
test: /[\\/]node_modules[\\/](?!vue)(.*)[\\/]/,
196+
name: 'vendor',
197+
chunks: 'initial',
198+
},
199+
}
200+
}
170201
},
171202
devServer: {
172203
contentBase: path.join(__dirname, 'public'),

0 commit comments

Comments
 (0)