Last active
October 28, 2018 17:02
-
-
Save kavitshah8/1a27e3207c6ecaf87220cc765ffb6257 to your computer and use it in GitHub Desktop.
Webpack Configs
This file contains 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
var config = { | |
entry: { | |
app: addEntryPoint('./src/Router.jsx'), | |
vendor: ['lodash', 'react', 'react-router', 'react-dom', 'rc-slider'] | |
}, | |
output: { | |
path: options.devServer ? path.join( __dirname, 'public', 'js') : 'public', | |
filename: '[name]-[chunkhash].js', | |
publicPath: '', | |
}, | |
plugins: [ | |
new CommonsChunkPlugin({ | |
name: 'commons', | |
filename: 'commons-[hash].js', | |
chunks: ['vendor', 'app'] | |
}), | |
new HtmlWebpackPlugin({ | |
filename: 'index.html', | |
template: path.join( __dirname, 'src', 'index.tpl.html'), | |
chunks: ['commons', 'app'] | |
}), | |
new CopyWebpackPlugin([{ | |
from: path.join(__dirname, 'src', 'assets', 'images'), | |
to: 'images' | |
}]) | |
].concat(plugins) | |
}; |
This file contains 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
function addEntryPoint(entryPoint) { | |
var entry = ['babel-polyfill', entryPoint]; | |
if (options.hotReload) { | |
entry = [ | |
'webpack-dev-server/client?http://localhost:3443', | |
'webpack/hot/dev-server' | |
].concat(entry); | |
} | |
return entry; | |
} | |
var config = { | |
entry: addEntryPoint('./src/Router.jsx'), | |
output: { | |
path: options.devServer ? path.join( __dirname, 'public', 'js') : 'public', | |
filename: 'build.js', | |
publicPath: '', | |
}, | |
plugins: [ | |
new HtmlWebpackPlugin({ | |
filename: 'index.html', | |
template: path.join( __dirname, 'src', 'index.tpl.html') | |
}), | |
new CopyWebpackPlugin([ | |
{from: path.join(__dirname, 'src', 'assets', 'images'), to: 'images'} | |
]) | |
].concat(plugins) | |
}; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment