Created
December 20, 2016 22:51
-
-
Save vaalentin/117ee4be30af0b7fe8ddc74174651d43 to your computer and use it in GitHub Desktop.
Webpack2 (still not working)
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 webpack = require('webpack'); | |
var HtmlWebpackPlugin = require('html-webpack-plugin'); | |
module.exports = { | |
entry: './src/index.js', | |
output: { | |
filename: 'bundle.js' | |
}, | |
resolve: { | |
modules: [ | |
'node_modules' | |
], | |
extensions: ['.js'] | |
}, | |
module: { | |
rules: [ | |
{ | |
test: /\.js$/, | |
exclude: /node_modules/, | |
loaders: 'buble-loader' | |
}, | |
{ | |
test: /\.css$/, | |
loaders: [ | |
{ | |
loader: 'style-loader' | |
}, | |
{ | |
loader: 'css-loader', | |
} | |
] | |
} | |
] | |
}, | |
plugins: [ | |
new HtmlWebpackPlugin({ | |
template: './src/index.html', | |
inject: 'body' | |
}), | |
new webpack.DefinePlugin({ | |
PRODUCTION: false | |
}) | |
], | |
devtool: 'cheap-eval-source', | |
devServer: { | |
contentBase: './src', | |
inline: true, | |
historyApiFallback: true | |
}, | |
performance: { | |
hints: false | |
} | |
}; |
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 webpack = require('webpack'); | |
var HtmlWebpackPlugin = require('html-webpack-plugin'); | |
var ExtractTextPlugin = require('extract-text-webpack-plugin'); | |
module.exports = { | |
context: __dirname, | |
entry: './src/index.js', | |
output: { | |
path: './dist', | |
filename: '[hash].js' | |
}, | |
resolve: { | |
modules: [ | |
'node_modules' | |
], | |
extensions: ['.js'] | |
}, | |
module: { | |
rules: [ | |
{ | |
test: /\.js$/, | |
exclude: /node_modules/, | |
loaders: 'buble-loader' | |
}, | |
{ | |
test: /\.css$/, | |
loaders: ExtractTextPlugin.extract({ | |
fallbackLoader: 'style-loader', | |
loader: 'css-loader' | |
}) | |
} | |
] | |
}, | |
plugins: [ | |
new HtmlWebpackPlugin({ | |
template: './src/index.html', | |
inject: 'body', | |
minify: { | |
removeComments: true, | |
collapseWhitespace: true | |
} | |
}), | |
new ExtractTextPlugin('[hash].css'), | |
new webpack.DefinePlugin({ | |
PRODUCTION: true | |
}), | |
new webpack.optimize.UglifyJsPlugin({ | |
compress: { | |
drop_console: true | |
}, | |
comments: false | |
}), | |
new webpack.optimize.OccurrenceOrderPlugin(true), | |
new webpack.LoaderOptionsPlugin({ | |
minimize: true, | |
debug: false | |
}) | |
] | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment