Advertisement
FabioMurtas

configWebPackTailwind

Jun 28th, 2023
1,056
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //config webPack
  2.  
  3. const path = require('path');
  4. const HtmlWebpackPlugin = require('html-webpack-plugin');
  5. const CopyWebpackPlugin = require('copy-webpack-plugin');
  6.  
  7. module.exports = {
  8.   entry: {
  9.     index: './src/index.js',
  10.     registrazione: './src/registrazione.js',
  11.     creaSegnalazione: './src/creaSegnalazione.js'
  12.   },
  13.   output: {
  14.     path: path.resolve(__dirname, 'dist'),
  15.     filename: '[name].bundle.js',
  16.     clean: true
  17.   },
  18.   module: {
  19.     rules: [
  20.       // ... altre regole ...
  21.       {
  22.         test: /\.css$/,
  23.         use: [
  24.           'style-loader',
  25.           'css-loader',
  26.           {
  27.             loader: 'postcss-loader',
  28.             options: {
  29.               postcssOptions: {
  30.                 plugins: [
  31.                   require('tailwindcss'),
  32.                   // Altri plugin PostCSS se necessario
  33.                 ],
  34.                 minimize: true // Abilita la minificazione CSS
  35.               }
  36.             }
  37.           }
  38.         ],
  39.       },
  40.     ],
  41.   },
  42.   plugins: [
  43.     new CopyWebpackPlugin({
  44.       patterns: [
  45.         { from: 'src/css', to: 'css' }, // Copia tutti i file dalla cartella "src/css" alla cartella "dist/css"
  46.       ],
  47.     }),
  48.     new HtmlWebpackPlugin({
  49.       template: './src/index.html',
  50.       chunks: ['index'],
  51.       filename: 'index.html'
  52.     }),
  53.     new HtmlWebpackPlugin({
  54.         template: './src/registrazione.html',
  55.         chunks: ['registrazione'],
  56.         filename: 'registrazione.html'
  57.       }),
  58.      
  59.     new HtmlWebpackPlugin({
  60.       template: './src/homeSegnalatore.html',
  61.       chunks: ['homeSegnalatore'],
  62.       filename: 'homeSegnalatore.html'
  63.     }),
  64.     new HtmlWebpackPlugin({
  65.       template: './src/creaSegnalazione.html',
  66.       chunks: ['creaSegnalazione'],
  67.       filename: 'creaSegnalazione.html'
  68.     })
  69.   ],
  70.   devServer: {
  71.     static: {
  72.       directory: path.resolve(__dirname, 'dist'),
  73.     },
  74.     port: 3000,
  75.     open: true,
  76.     hot: true,
  77.     compress: true,
  78.     historyApiFallback: true
  79.   },
  80.   mode: 'development',
  81.   devtool: 'source-map'
  82. };
  83.  
  84.  
  85. //config tailwind
  86. /** @type {import('tailwindcss').Config} */
  87. module.exports = {
  88.   content: ['./dist/*.html'],
  89.   theme: {
  90.     extend: {},
  91.   },
  92.   plugins: [],
  93. }
  94.  
  95.  
  96. //postcss config
  97. const tailwindcss = require('tailwindcss');
  98. module.exports = {
  99.   plugins: [
  100.     require("tailwindcss")("./tailwind.config.js"),
  101.     require("autoprefixer")
  102.   ],
  103. };
  104.  
  105. //packagejson
  106.  
  107. {
  108.   "name": "sdsapp",
  109.   "version": "1.0.0",
  110.   "description": "",
  111.   "main": "index.js",
  112.   "scripts": {
  113.     "build": "webpack --mode production",
  114.     "watch": "webpack --mode development --watch",
  115.     "start": "webpack serve"
  116.   },
  117.   "keywords": [],
  118.   "author": "",
  119.   "license": "ISC",
  120.   "devDependencies": {
  121.     "@firebase/analytics": "^0.10.0",
  122.     "@firebase/app": "^0.9.13",
  123.     "autoprefixer": "^10.4.14",
  124.     "copy-webpack-plugin": "^11.0.0",
  125.     "css-loader": "^6.8.1",
  126.     "html-webpack-plugin": "^5.5.3",
  127.     "postcss": "^8.4.24",
  128.     "postcss-loader": "^7.3.3",
  129.     "style-loader": "^3.3.3",
  130.     "tailwindcss": "^3.3.2",
  131.     "webpack": "^5.88.0",
  132.     "webpack-cli": "^5.1.4",
  133.     "webpack-dev-server": "^4.15.1"
  134.   },
  135.   "dependencies": {
  136.     "body-parser": "^1.20.2",
  137.     "express": "^4.18.2",
  138.     "firebase": "^9.23.0",
  139.     "mysql": "^2.18.1"
  140.   }
  141. }
  142.  
  143.  
  144. // boil
  145. ---dist
  146. ---node_modules
  147. ---src
  148.   ---backend
  149.   ---css
  150.     ---style.css
  151.   ---(...file js e html vari)
  152.   ---input.css
  153. ---gitignore
  154. ---package-lock.json
  155. ---package.json
  156. ---postcss.config.js
  157. ---tailwind.js
  158. ---webpack.config.js
  159.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement