factorio-server-manager/webpack.config.js

106 lines
3.4 KiB
JavaScript
Raw Normal View History

const path = require('path');
2018-08-20 19:38:33 +02:00
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
/* 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");
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
},
output: {
2018-08-29 03:54:52 +02:00
filename: '[name].js',
path: path.resolve(__dirname, 'app'),
publicPath: ""
},
resolve: {
alias: {
Utilities: path.resolve('ui/js/')
},
extensions: ['.js', '.json', '.jsx']
},
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: {
name: loader_path => {
2018-08-29 00:47:59 +02:00
if(!/node_modules/.test(loader_path)) {
return "/images/[name].[ext]?[hash]";
2018-08-20 19:38:33 +02:00
}
return (
"/images/vendor/" +
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: {
name: loader_path => {
2018-08-29 00:47:59 +02:00
if (!/node_modules/.test(loader_path)) {
return '/fonts/[name].[ext]?[hash]';
2018-08-20 19:38:33 +02:00
}
return (
'/fonts/vendor/' +
loader_path
2018-08-20 19:38:33 +02:00
.replace(/\\/g, '/')
.replace(/((.*(node_modules))|fonts|font|assets)\//g, '') +
2018-08-20 19:38:33 +02:00
'?[hash]'
);
},
}
}
]
}
]
2018-08-20 02:39:56 +02:00
},
performance: {
hints: false
2018-08-20 19:38:33 +02:00
},
plugins: [
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
})
]
}