Skip to content

Instantly share code, notes, and snippets.

@lattespirit
Last active November 6, 2019 12:57
Show Gist options
  • Save lattespirit/428849011ca1b7b5f4d04fcccd1d6e6d to your computer and use it in GitHub Desktop.
Save lattespirit/428849011ca1b7b5f4d04fcccd1d6e6d to your computer and use it in GitHub Desktop.
Setting up TailwindCSS and Vue.js
import Vue from 'vue';
const files = require.context('./', true, /\.vue$/i)
files.keys().map(key => Vue.component(key.split('/').pop().split('.')[0], files(key).default))
new Vue({
el: "#app",
})
npm init -y
npm install tailwindcss vue
npm install -D babel-loader @babel/core @babel/preset-env css-loader file-loader postcss-loader vue-loader vue-template-compiler webpack webpack-cli uglifyjs-webpack-plugin postcss autoprefixer
var path = require('path')
var webpack = require('webpack')
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
const VueLoaderPlugin = require('vue-loader/lib/plugin')
module.exports = {
mode: "production",
entry: './main.js',
output: {
path: path.resolve(__dirname, './dist'),
publicPath: '/dist/',
filename: 'build.js'
},
module: {
rules: [{
test: /\.css$/,
use: [
'vue-style-loader',
'css-loader',
{
loader: 'postcss-loader',
options: {
ident: 'postcss',
plugins: [
require('tailwindcss'),
require('autoprefixer'),
]
}
}
],
},
{
test: /\.vue$/,
loader: 'vue-loader'
},
{
test: /\.js$/,
loader: 'babel-loader',
exclude: /node_modules/
},
{
test: /\.(png|jpg|gif|svg)$/,
loader: 'file-loader',
options: {
name: '[name].[ext]?[hash]'
}
}
]
},
resolve: {
alias: {
'vue$': 'vue/dist/vue.esm.js'
},
extensions: ['*', '.js', '.vue', '.json']
},
devServer: {
historyApiFallback: true,
noInfo: true,
overlay: true
},
performance: {
hints: false
},
devtool: '#eval-source-map',
plugins: [
new VueLoaderPlugin()
],
optimization: {
minimizer: [new UglifyJsPlugin()],
},
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment