Variables loader
Webpack loader to parse variables
Install
npm install variables-loader
or
yarn add variables-loader
Usage
env.js
module { return URL: "http://www.example.com" ;};
webpack.config.js
moduleexports = module: rules: test: /\.x?$/ use: "variables-loader" ;
How will the result be?
before in Link.jsx
import React from "react"; const LinkComponent = <a ="[[URL]]">Link</a>; ;
after in Link.jsx
import React from "react"; const LinkComponent = <a ="http://www.example.com">Link</a>; ;
Options
fileName
Type String|Function
Default: env.js
webpack.config.js
String
moduleexports = module: rules: test: /\.x?$/ loader: "variables-loader" options: fileName: "environments.js" ;
Function
moduleexports = module: rules: test: /\.x?$/ loader: "variables-loader" options: { if processenvNODE_ENV === "development" return "environments.test.js"; return "environments.js"; } ;
format
Type String<js,json,txt>|Function<js,json,env>
Default: js
webpack.config.js
String
moduleexports = module: rules: test: /\.x?$/ loader: "variables-loader" options: format: "js" ;
Function
moduleexports = module: rules: test: /\.x?$/ loader: "variables-loader" options: { if processenvNODE_ENV === "development" return "json"; return "js"; } ;
marker
Type String|Function|Array
Default: [[]]
webpack.config.js
String
moduleexports = module: rules: test: /\.x?$/ loader: "variables-loader" options: marker: "{{}}" ;
Function
moduleexports = module: rules: test: /\.x?$/ loader: "variables-loader" options: { if processenvNODE_ENV === "development" return "{{}}"; return "[[]]"; } ;
NPM Statistics
Download stats for this NPM package
License
Variables Loader is open source software licensed as MIT.