App.css is not recreated again

nevermind, I had to import it in app.js

I removed app.css from priv/static/css and wanted to recreate it. So I ran npm run deploy from the assets dir. It recompiled app.js phoenix.png ... but it did not recreate the app.css file.

I have the default webpack.config.js file. The only new package I added was "@babel/plugin-transform-runtime": "^7.10.1", and made changes in .bablerc.

I created a new phx project and I could not replicate the err there.

I am using phoenix 1.4.16

> webpack --mode=production -p

Hash: 1690912616fe7f8e9e92
Version: webpack 4.41.5
Time: 787ms
Built at: 05/30/2020 3:16:13 PM
                Asset       Size  Chunks             Chunk Names
       ../favicon.ico   1.23 KiB          [emitted]  
../images/phoenix.png   13.6 KiB          [emitted]  
        ../robots.txt  202 bytes          [emitted]  
               app.js   9.66 KiB       0  [emitted]  ./js/app.js
Entrypoint ./js/app.js = app.js
[2] multi ./js/app.js 28 bytes {0} [built]
[3] ./js/app.js 4.61 KiB {0} [built]
    + 3 hidden modules

Response from webpack

:wave:

Do you still import app.(s)css in app.js? Can you post your webpack.config.js?

1 Like

oh yes i still import app.css in app.js. Is there a better way?

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');

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, 'css-loader']
      }
    ]
  },
  plugins: [
    new MiniCssExtractPlugin({ filename: '../css/app.css' }),
    new CopyWebpackPlugin([{ from: 'static/', to: '../' }])
  ]
});

It’s the default webpack config provided by the framework

No, it’s just I once deleted the line import "../css/app.css" from app.js and was wondering where the styles went …

It’s the default webpack config provided by the framework

It seems fine …

1 Like