Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Link to stylesheet not being deleted in certain cases #32

Merged
merged 2 commits into from
Oct 22, 2017
Merged

Link to stylesheet not being deleted in certain cases #32

merged 2 commits into from
Oct 22, 2017

Conversation

ballwood
Copy link
Contributor

@ballwood ballwood commented Oct 21, 2017

Seems the issue is to do with the file path searched for. HtmlWebpackPlugin appends the public path to the asset url (e.g. ../../../) in the src when including but StyleExtWebpackPlugin doesn't use this when searching for the link tag the second time, this is why the link is appended not replaced.

Code from HtmlWebpackPlugin here compared to code in the main repo here

Original issue

@numical
Copy link
Owner

numical commented Oct 22, 2017

Thank you!
Normally I would insist on first seeing a failing test that the PR fixes.
However as I have done so little maintenance on this plugin in recent months I would be daft not to accept this, particularly as it is a lift'n'shift from HtmlWebpackPlugin code.
I have pulled your changes and will release with an updated README and dependenices.

@numical numical merged commit bd218eb into numical:master Oct 22, 2017
@ballwood
Copy link
Contributor Author

ballwood commented Oct 22, 2017

@numical thanks dude, I was working off this configuration below. Its a bit of a weird one but exhibited the bug.

const path = require('path');
const webpack = require('webpack');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const CleanWebpackPlugin = require('clean-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const StyleExtHtmlWebpackPlugin = require('style-ext-html-webpack-plugin');

const config = {
  entry: {
    app1: './src/app1.js',
    app2: './src/app2.js'
  },
  devtool: false,
  output: {
    path: path.resolve(__dirname, 'dist'),
    filename: '[name]/app.js'
  },
  module: {
    rules: [
      {
        test: /\.css$/,
        use: ExtractTextPlugin.extract({
          fallback: "style-loader",
          use: "css-loader"
        })
      }
    ]
  },
  plugins: [
    new CleanWebpackPlugin('./dist'),
    new webpack.optimize.CommonsChunkPlugin({
      name: 'shared'
    }),
    new ExtractTextPlugin({
      filename: '[name]/style.css',
      allChunks: true
    }),
    new HtmlWebpackPlugin({
      chunks: ['shared', 'app1'],
      filename: 'app1/index.html'
    }),
    new StyleExtHtmlWebpackPlugin({
      file: 'app1/style.css',
      chunks: ['app1'],
      position: 'plugin'
    }),
    new HtmlWebpackPlugin({
      chunks: ['shared', 'app2'],
      filename: 'app2/index.html'
    }),
    new StyleExtHtmlWebpackPlugin({
      file: 'app2/style.css',
      chunks: ['app2'],
      position: 'plugin'
    })
  ]
};

module.exports = config;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants