Snowpack plugin that processes JavaScript assets through the Closure Compiler, reducing file sizes and performing static code analysis.
This plugin requires an LTS Node version (v8.0.0+) and Snowpack v2.0.0+.
Using npm:
npm install --save-dev snowpack-plugin-closure-compiler
Create a snowpack.config.js
configuration file and import the plugin:
const dsv = require('snowpack-plugin-dsv');
module.exports = {
mount: {
public: { url: '/', static: true },
src: { url: '/dist' },
},
plugins: ['snowpack-plugin-closure-compiler', {
compilationLevel: "SIMPLE",
outputFile: "main.js",
bundle: false
}],
};
Type: boolean
Default: true
The Closure Compiler can bundle all JavaScript files into and this is the default processing for the plugin. If JavaScript files need to not be bundled, use false
.
Type: string
Default: index.js
Specify resource name after compilation, placed inside of mount.src.url
directory.
Type: string
Default: SIMPLE
Determines type of processing performed by Closure Compiler - specify one of BUNDLE
, WHITESPACE_ONLY
, SIMPLE
, ADVANCED
Type: string
Default: ECMASCRIPT_NEXT
Specifies what the most recent level of ECMAScript used in the source code. One of the following: ECMASCRIPT3
, ECMASCRIPT5
, ECMASCRIPT5_STRICT
, ECMASCRIPT_2015
, ECMASCRIPT_2016
, ECMASCRIPT_2017
, ECMASCRIPT_2018
, ECMASCRIPT_2019
, STABLE
, ECMASCRIPT_NEXT
Type: string
Default: ECMASCRIPT5
Determines ECMAScript version of output file - use one of the values referenced in the languageIn
property.