Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update webpack config file. #39

Merged
merged 1 commit into from
Dec 14, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 13 additions & 10 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,26 @@ var HtmlWebpackPlugin = require( 'html-webpack-plugin' );
var autoprefixer = require( 'autoprefixer' );
var ExtractTextPlugin = require( 'extract-text-webpack-plugin' );
var CopyWebpackPlugin = require( 'copy-webpack-plugin' );
var entryPath = path.join( __dirname, 'src/static/index.js' );
var outputPath = path.join( __dirname, 'dist' );

console.log( 'WEBPACK GO!');

// detemine build env
// determine build env
var TARGET_ENV = process.env.npm_lifecycle_event === 'build' ? 'production' : 'development';
var outputFilename = TARGET_ENV == 'production' ? '[name]-[hash].js' : '[name].js'

// common webpack config
var commonConfig = {

output: {
path: path.resolve( __dirname, 'dist/' ),
filename: '[hash].js',
path: outputPath,
filename: path.join( 'static/js/', outputFilename ),
publicPath: '/'
},

resolve: {
modulesDirectories: ['node_modules'],
extensions: ['', '.js', '.elm']
extensions: ['', '.js', '.elm']
},

module: {
Expand Down Expand Up @@ -54,12 +57,12 @@ if ( TARGET_ENV === 'development' ) {

entry: [
'webpack-dev-server/client?http://localhost:8080',
path.join( __dirname, 'src/static/index.js' )
entryPath
],

devServer: {
inline: true,
progress: true
// serve index.html in place of 404 responses
historyApiFallback: true,
},

module: {
Expand Down Expand Up @@ -90,7 +93,7 @@ if ( TARGET_ENV === 'production' ) {

module.exports = merge( commonConfig, {

entry: path.join( __dirname, 'src/static/index.js' ),
entry: entryPath,

module: {
loaders: [
Expand Down Expand Up @@ -124,7 +127,7 @@ if ( TARGET_ENV === 'production' ) {
new webpack.optimize.OccurenceOrderPlugin(),

// extract CSS into a separate file
new ExtractTextPlugin( './[hash].css', { allChunks: true } ),
new ExtractTextPlugin( 'static/css/[name]-[hash].css', { allChunks: true } ),

// minify & mangle JS/CSS
new webpack.optimize.UglifyJsPlugin({
Expand Down