strong textWebpack configuration is as follows :
webpack.config.js is as follows:
const path = require('path');
const webpack = require('webpack');
const CopyWebpackPlugin = require('copy-webpack-plugin');
module.exports = {
context: path.resolve(__dirname, './src'),
entry: {
app: './app.js',
},
plugins: [
new CopyWebpackPlugin([
{from: '../public'},
{from: '../src/fonts', to: 'fonts'},
{from: '../src/images'}
]),
new webpack.EnvironmentPlugin(['REACT_APP_OMNITURE_URL']),
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify('production')
}),
new webpack.optimize.UglifyJsPlugin()
],
output: {
path: path.resolve(__dirname, './build'),
filename: '[name].bundle.js',
},
module: {
rules: [
{
test: /\.js$/,
exclude: [/node_modules/],
use: [{
loader: 'babel-loader',
options: {presets: ["es2015", "react"]},
}],
},
{
test: /\.svg$/,
exclude: [/node_modules/],
use: [{loader: 'svg-react-loader'}],
},
{
test: /\.scss$/,
use: [{
loader: "style-loader"
}, {
loader: "css-loader"
}, {
loader: "sass-loader"
}]
},
{
test: /\.(png|woff|woff2|eot|otf|ttf)$/,
loader: 'url-loader?limit=100000'
}
],
},
devServer: {
contentBase: path.resolve(__dirname, './public'),
disableHostCheck: true,
historyApiFallback: true
},
};
What I need to achieve is to read this REACT_APP_OMNITURE_URLenvironmental variable in index.html as follows:
<script type="text/javascript" src="//%REACT_APP_OMNITURE_URL%/analytics.js"></script>
Any help on this front?
Plus we are using Bamboo to dynamically pass us per environment variables. How can we assign those variables to node variables and Use in plugin?