0

Im experiencing a problem with webpack.

The plugin HtmlWebpackPlugin is not creating the tag And I cant figure it out why. Only the JS tag is included.

as plugins I have

  new HtmlWebpackPlugin({
    inject: false,
    // hash: true,
    template: __dirname + '/../src/app/Views/layouts/layout-template.phtml',
    filename: __dirname + '/../src/app/Views/layouts/layout.phtml',
  }),
  new MiniCssExtractPlugin({
    filename: 'css/[name].css'
  })

as rules:

  {
    test: /\.(sa|sc|c)ss$/,
    use: [
      {
        loader: MiniCssExtractPlugin.loader,
      },
      'css-loader',
      'postcss-loader',
      'sass-loader',
    ],
  },

I would appreciate help. Thanks.

2 Answers 2

1

You are telling to HTMLWebpackPlugin not to inject them by inject: false. Just remove inject: false attribute.

Sign up to request clarification or add additional context in comments.

5 Comments

But that inject:false is to prevent the default injection. If i take that option of i get two js injections, the default and the one in the template. But either ways i can't make the link tag appear.
This don't return any results. <% for (let css in htmlWebpackPlugin.files.css) { %> <link rel="stylesheet" href="<%= htmlWebpackPlugin.files.css[css] %>"> <% } %>
Ha, so can you share your layout-template.phtml?
Thank you brother, but i figured it out. Posted ir above. Since im not used to webpack i guess it's a newbie mistake. Maybe will help others. Cheers!
This is one solution, other solution would to import the styles file from within index.js import './scss/styles.css';
1

I just figure it out. I needed to include the scss also as an entry point.

entry: {
      main: [
        './src/private/index.js',
        './src/private/scss/style.scss'
      ],
},

I'm kinda new to webpack, and the documentation or examples, or are outdated or confusing.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.