YahooArchive / strip-loader

Webpack loader to strip arbitrary functions out of your production code.
Other
282 stars 14 forks source link

Loader fails to strip if match is on the first line of a file. #9

Closed husterk closed 8 years ago

husterk commented 8 years ago

I have a simple test setup for the strip loader which includes a file that has a single line containing console.log('File loaded!'); which is not being stripped properly. However, if I simply add a blank line to the top of the file and move the console.log('File loaded!'); statement to the second line then the strip loader works properly. It appears as though the strip loader always fails to match if a match exists on the first line of a file. My strip loader configuration is shown below.

var webpackStripLoader = require('strip-loader');
var stripLoaderSettings = {
    test: /(\.js$|\.es6$)/,
    exclude: /node_modules/,
    loader: webpackStripLoader.loader('console.log')
}
tikotzky commented 8 years ago

This also happens if its on the last line and does not have a semicolon at the end of the line.

Vijar commented 8 years ago

Fixed by #10