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

Output to a file #36

Conversation

stephencookdev
Copy link

@stephencookdev stephencookdev commented Feb 13, 2020

This PR adds in the ability to output to a file, as well as just to the console. (should resolve #8)

For example, with a config of:

new UnusedWebpackPlugin({
  // Source directories
  directories: [
    path.join(__dirname, 'awesome-module'),
    path.join(__dirname, 'simple-module'),
  ],
  // Exclude patterns
  exclude: ['**/*.test.js'],
  // Root directory (optional)
  root: __dirname,
  failOnUnused: false,
})

you would get this logged to the console:

*** Unused Plugin ***
4 unused source files found.

● awesome-module
    • actions/destroy.js
    • config/index.js

● simple-module
    • routes/index.js
    • utils/date.js

*** Unused Plugin ***

but with the following config, instead:

new UnusedWebpackPlugin({
  // Source directories
  directories: [
    path.join(__dirname, 'awesome-module'),
    path.join(__dirname, 'simple-module'),
  ],
  // Exclude patterns
  exclude: ['**/*.test.js'],
  // Root directory (optional)
  root: __dirname,
  failOnUnused: false,
  outputFile: 'unused_manifest',
})

then you would get nothing printing to the console, but cat dist/unused_manifest would return:

/some/user/path/unused-webpack-plugin/examples/awesome-module/actions/destroy.js                                                                                        
/some/user/path/unused-webpack-plugin/examples/awesome-module/config/index.js
/some/user/path/unused-webpack-plugin/examples/simple-module/routes/index.js
/some/user/path/unused-webpack-plugin/examples/simple-module/utils/date.js

@stephencookdev stephencookdev changed the title Export output file Output to a file Feb 13, 2020
@stephencookdev
Copy link
Author

D'oh, I've just noticed that #35 also does what I've done here 😂

I think strictly speaking compilation.assets is the preferred way to output new files in webpack, but I don't have a strong opinion, other than feature existing in some form 🙂

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.

Add support for export output
1 participant