Elixir Helpers
Though you likely won't need to reference many of these helpers directly, they, nonetheless, are available to you, should you wish to manually configure/modify the provided webpack.config.js
file.
Elixir.inProduction
This property may be used to determine the current environment for the build. It simply defers to process.env.NODE_ENV === 'production'
.
if (Elixir.inProduction) {
// Modify webpack.config.js as needed.
}
This can be particularly useful for plugins or tasks that are only necessary for your production-ready build.
Elixir.File
This property contains a reference to Laravel Elixir's File
class, which includes a number of useful helpers.
let file = new Elixir.File('path/to/file.js');
On this instance, the following methods are available:
File.exists()
let exists = File.exists('path/to/file.js');
This static method call will determine if the given file path exists.
file.read()
let contents = new Elixir.File('path/to/file.js').read();
The read
method will naturally read and return the file's contents.
file.write()
new Elixir.File('path/to/new/file.txt').write('Hello World');
The write
method allows you to write the provided contents to a new file.
file.delete()
new Elixir.File('file.js').delete();
The delete
method will unlink/delete the file associated with the current instance.
file.parsePath()
let segments = new Elixir.File('file.js').parsePath();
This method will parse the provided file into segments. The returned object will contain details of each segment of the path, including the extension, the base directory, the file name, and more.
file.minify()
new Elixir.File('file.js').minify();
Should you need to manually minify a file (without using the mix.minify()
call in your webpack.elixir.js
file), you may defer to this method.