Created
May 14, 2018 16:19
-
-
Save avanslaars/e8cdf2324c47aafa527573d1043cb7ec to your computer and use it in GitHub Desktop.
Sample config to output multiple HTML files with a single JS bundle for testing multiple React and ReactDOM versions via CDN
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const path = require('path') | |
const HtmlWebpackPlugin = require('html-webpack-plugin') | |
module.exports = { | |
entry: './src/index.js', | |
output: { | |
path: path.join(__dirname, 'build'), | |
filename: 'app.bundle.js' | |
}, | |
module: { | |
rules: [ | |
{ | |
test: /\.js$/, | |
loader: 'babel-loader', | |
options: { | |
plugins: [ | |
'transform-class-properties', | |
'transform-object-rest-spread' | |
], | |
presets: ['env', 'react'] | |
}, | |
exclude: /node_modules/ | |
}, | |
{ | |
test: /\.css$/, | |
use: ['style-loader', 'css-loader'], | |
exclude: /node_modules/ | |
} | |
] | |
}, | |
externals: { | |
react: 'React', | |
'react-dom': 'ReactDOM' | |
}, | |
devtool: 'sourcemap', | |
plugins: [ | |
new HtmlWebpackPlugin({ | |
template: './src/15/index.html', | |
filename: 'react_15.html', | |
inject: 'body' | |
}), | |
new HtmlWebpackPlugin({ | |
template: './src/16/index.html', | |
filename: 'react_16.html', | |
inject: 'body' | |
}), | |
new HtmlWebpackPlugin({ | |
template: './src/16_3/index.html', | |
filename: 'react_16_3.html', | |
inject: 'body' | |
}) | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment