2018-08-20 02:33:36 +02:00
|
|
|
const path = require('path');
|
2018-08-20 19:38:33 +02:00
|
|
|
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
|
2018-08-20 02:33:36 +02:00
|
|
|
|
2018-08-29 03:46:30 +02:00
|
|
|
/* TODO remove when webpack fixed this error:
|
|
|
|
* Links to this error:
|
|
|
|
* https://github.com/webpack/webpack/issues/7300
|
|
|
|
* https://github.com/JeffreyWay/laravel-mix/pull/1495
|
|
|
|
* https://github.com/webpack-contrib/mini-css-extract-plugin/issues/151
|
|
|
|
* and more...
|
|
|
|
*
|
|
|
|
* This will be, as far as i know, fixed in webpack 5, it is currently in development
|
|
|
|
*/
|
|
|
|
const FixStyleOnlyEntriesPlugin = require("webpack-fix-style-only-entries");
|
|
|
|
|
2018-08-20 02:33:36 +02:00
|
|
|
module.exports = {
|
2018-08-20 19:38:33 +02:00
|
|
|
entry: {
|
2018-08-29 03:54:52 +02:00
|
|
|
bundle: './ui/index.js',
|
|
|
|
style: './ui/index.scss'
|
2018-08-20 19:38:33 +02:00
|
|
|
},
|
2018-08-20 02:33:36 +02:00
|
|
|
output: {
|
2018-08-29 03:54:52 +02:00
|
|
|
filename: '[name].js',
|
2018-08-29 03:16:29 +02:00
|
|
|
path: path.resolve(__dirname, 'app'),
|
|
|
|
publicPath: ""
|
2018-08-20 02:33:36 +02:00
|
|
|
},
|
|
|
|
resolve: {
|
|
|
|
alias: {
|
2018-08-29 03:16:29 +02:00
|
|
|
Utilities: path.resolve('ui/js/')
|
2018-08-20 02:33:36 +02:00
|
|
|
},
|
2018-08-24 18:52:05 +02:00
|
|
|
extensions: ['.js', '.json', '.jsx']
|
2018-08-20 02:33:36 +02:00
|
|
|
},
|
|
|
|
module: {
|
|
|
|
rules: [
|
|
|
|
{
|
|
|
|
test: /\.jsx?$/,
|
|
|
|
exclude: /node_modules/,
|
|
|
|
use: {
|
|
|
|
loader: 'babel-loader'
|
|
|
|
}
|
2018-08-20 19:38:33 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.scss$/,
|
|
|
|
use: [
|
|
|
|
MiniCssExtractPlugin.loader,
|
|
|
|
"css-loader",
|
2018-08-29 00:47:59 +02:00
|
|
|
"resolve-url-loader",
|
|
|
|
"sass-loader?sourceMap"
|
2018-08-20 19:38:33 +02:00
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /(\.(png|jpe?g|gif)$|^((?!font).)*\.svg$)/,
|
|
|
|
loaders: [
|
|
|
|
{
|
|
|
|
loader: "file-loader",
|
|
|
|
options: {
|
2018-08-24 18:52:05 +02:00
|
|
|
name: loader_path => {
|
2018-08-29 00:47:59 +02:00
|
|
|
if(!/node_modules/.test(loader_path)) {
|
2018-08-29 03:16:29 +02:00
|
|
|
return "/images/[name].[ext]?[hash]";
|
2018-08-20 19:38:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
2018-08-29 03:16:29 +02:00
|
|
|
"/images/vendor/" +
|
2018-08-24 18:52:05 +02:00
|
|
|
loader_path.replace(/\\/g, "/")
|
|
|
|
.replace(/((.*(node_modules))|images|image|img|assets)\//g, '') +
|
2018-08-20 19:38:33 +02:00
|
|
|
'?[hash]'
|
|
|
|
);
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /(\.(woff2?|ttf|eot|otf)$|font.*\.svg$)/,
|
|
|
|
loaders: [
|
|
|
|
{
|
|
|
|
loader: "file-loader",
|
|
|
|
options: {
|
2018-08-24 18:52:05 +02:00
|
|
|
name: loader_path => {
|
2018-08-29 00:47:59 +02:00
|
|
|
if (!/node_modules/.test(loader_path)) {
|
2018-08-29 03:16:29 +02:00
|
|
|
return '/fonts/[name].[ext]?[hash]';
|
2018-08-20 19:38:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
2018-08-29 03:16:29 +02:00
|
|
|
'/fonts/vendor/' +
|
2018-08-24 18:52:05 +02:00
|
|
|
loader_path
|
2018-08-20 19:38:33 +02:00
|
|
|
.replace(/\\/g, '/')
|
2018-08-24 18:52:05 +02:00
|
|
|
.replace(/((.*(node_modules))|fonts|font|assets)\//g, '') +
|
2018-08-20 19:38:33 +02:00
|
|
|
'?[hash]'
|
|
|
|
);
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
2018-08-20 02:33:36 +02:00
|
|
|
}
|
|
|
|
]
|
2018-08-20 02:39:56 +02:00
|
|
|
},
|
|
|
|
performance: {
|
|
|
|
hints: false
|
2018-08-20 19:38:33 +02:00
|
|
|
},
|
|
|
|
plugins: [
|
2018-08-29 03:46:30 +02:00
|
|
|
new FixStyleOnlyEntriesPlugin(),
|
2018-08-20 19:38:33 +02:00
|
|
|
new MiniCssExtractPlugin({
|
2018-08-29 03:54:52 +02:00
|
|
|
filename: "[name].css"
|
2018-08-20 19:38:33 +02:00
|
|
|
})
|
|
|
|
]
|
2018-08-20 02:33:36 +02:00
|
|
|
}
|