I'm using middleman with webpack.
Thus my config.rb
contains this configuration for an external pipeline (webpack):
activate :external_pipeline,
name: :webpack,
command: build? ? 'yarn run build' : 'yarn run start',
source: '.tmp/dist',
latency: 1
and package.json
contains this:
"scripts": {
"build": "webpack --bail -p --config webpack.config.js",
"start": "webpack --watch --progress --color --config webpack.config.js"
},
This is how the webpack.config.js
looks like
// webpack.config.js
var path = require('path');
var webpack = require('webpack');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
module.exports = {
mode: 'development',
entry: {
application: './source/javascripts/application.js',
styles: './source/stylesheets/application.scss',
},
output: {
path: __dirname + '/.tmp/dist',
filename: '[name].js',
},
module: {
rules: [
{
test: /\.s[ac]ss$/i,
use: [
{
loader: 'file-loader',
options: {
name: '[name].css'
}
},
{
loader: 'sass-loader',
options: {
sourceMap: true
}
}
],
},
{
test: /\.css$/,
exclude: /node_modules/,
use: [
{
loader: MiniCssExtractPlugin.loader,
options: {
hmr: process.env.NODE_ENV === 'development',
},
},
'css-loader',
'postcss-loader',
]
},
{
test: /\.(png|svg|jpg|jpeg|gif)$/,
use: [
'file-loader',
],
},
{
test: /\.(woff(2)?|ttf|eot|svg|otf)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
loader: 'file-loader',
options: {
name: 'fonts/[name].[ext]?[hash]'
}
}
]
}
}
The page uses some custom fonts already (located in source/fonts
) but now I also want to use Font Awesome through webpack.
But somehow I'm unable to get it work, without copying the fonts manually from the font awesome font directory to source/fonts
folder.
I'm sure it is related to the webpack.config.js
but I can't figure out, how I have to integrate it.
Although I'm not sure whether it's relevant — this is how I included the SCSS:
// source/stylesheets/application.scsss
@charset "utf-8";
@import "../../node_modules/@fortawesome/fontawesome-free/scss/fontawesome.scss";
@import "../../node_modules/@fortawesome/fontawesome-free/scss/regular.scss";
PS: Just to clarify this. I want to use webpack to have all assets handled in one place (webpack). Therefore I don't have any interest in using font-awesome-middleman
or similar gems.