Created
April 11, 2020 16:24
-
-
Save pau-riosa/1092ebb7c4f8b91448ce3e5b9a92c82c to your computer and use it in GitHub Desktop.
Webpack Configuration with: [Tailwind CSS, Fontawesome Icons]
This file contains 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
$fa-font-path: "~@fortawesome/fontawesome-free/webfonts"; |
This file contains 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
/* This file is for your main application css. */ | |
/* fontawesome. */ | |
@import "variables"; | |
@import "@fortawesome/fontawesome-free/scss/brands"; | |
@import "@fortawesome/fontawesome-free/scss/regular"; | |
@import "@fortawesome/fontawesome-free/scss/solid"; | |
@import "@fortawesome/fontawesome-free/scss/fontawesome"; | |
/* end fontawesome. */ | |
@import "tailwindcss/base"; | |
@import "tailwindcss/components"; | |
@import "./components/nav"; | |
@import "./components/buttons"; | |
@import "tailwindcss/utilities"; |
This file contains 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
module.exports = { | |
plugins: [ | |
require('postcss-import'), | |
require('tailwindcss'), | |
require('autoprefixer') | |
], | |
}; |
This file contains 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
const path = require('path'); | |
const glob = require('glob'); | |
const MiniCssExtractPlugin = require('mini-css-extract-plugin'); | |
const TerserPlugin = require('terser-webpack-plugin'); | |
const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin'); | |
const CopyWebpackPlugin = require('copy-webpack-plugin'); | |
const webpack = require('webpack') | |
module.exports = (env, options) => ({ | |
optimization: { | |
minimizer: [ | |
new TerserPlugin({ cache: true, parallel: true, sourceMap: false }), | |
new OptimizeCSSAssetsPlugin({}) | |
] | |
}, | |
entry: { | |
'./js/app.js': glob.sync('./vendor/**/*.js').concat(['./js/app.js']) | |
}, | |
output: { | |
filename: 'app.js', | |
path: path.resolve(__dirname, '../priv/static/js') | |
}, | |
module: { | |
rules: [ | |
{ | |
test: /\.js$/, | |
exclude: /node_modules/, | |
use: { | |
loader: 'babel-loader' | |
} | |
}, | |
{ | |
test: /\.css$/, | |
use: [ | |
MiniCssExtractPlugin.loader, | |
{ | |
loader: 'css-loader', options: { } | |
}, | |
'postcss-loader', | |
], | |
}, | |
{ | |
test: /\.sass$|.scss$/, | |
use: [ | |
MiniCssExtractPlugin.loader, | |
{loader: 'css-loader', options: {importLoaders: 1}}, | |
{ | |
loader: 'postcss-loader', | |
options: { | |
sourceMap: true, | |
config: { | |
path: 'postcss.config.js' | |
} | |
} | |
}, | |
{loader: 'sass-loader?sourceMap'}, | |
] | |
}, | |
{ | |
test: /\.(woff(2)?|ttf|eot|svg)(\?v=\d+\.\d+\.\d+)?$/, | |
use: [ | |
{ | |
loader: 'file-loader', | |
options: { | |
name: '[name].[ext]', | |
outputPath: '../fonts' | |
} | |
} | |
] | |
} | |
] | |
}, | |
plugins: [ | |
new webpack.ProvidePlugin({ | |
// add jquery | |
$: 'jquery', | |
jQuery: 'jquery' | |
}), | |
new MiniCssExtractPlugin({ filename: '../css/app.css' }), | |
new CopyWebpackPlugin([{ from: 'static/', to: '../' }]) | |
] | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment