Skip to content

Instantly share code, notes, and snippets.

@jordic
Created January 18, 2017 12:34
Show Gist options
  • Save jordic/50d4bbae4f30ef315407452495929f20 to your computer and use it in GitHub Desktop.
Save jordic/50d4bbae4f30ef315407452495929f20 to your computer and use it in GitHub Desktop.
webpack static
// webpack.config.js
let ExtractTextPlugin = require("extract-text-webpack-plugin");
let HtmlWebpackPlugin = require('html-webpack-plugin');
let CopyWebpackPlugin = require('copy-webpack-plugin');
let path = require('path');
module.exports = {
entry: './src/index.js',
output: {
path: __dirname + '/dist',
filename: 'bundle_[hash].js'
},
devServer: {
contentBase: './dist/'
},
module: {
loaders: [
{test: /\.js$/, exclude: /node_modules/,
loader: 'babel-loader', query: {presets: ["es2015"]}},
{test: /\.scss$/,
loader: ExtractTextPlugin.extract({
fallbackLoader: "style-loader",
loader: ['css-loader', 'sass-loader', 'postcss-loader'],
})
},
{ test: /\.(jpe?g|png|gif|ttf|svg)$/i,
loader: "file-loader?name=/assets/[name].[ext]",
},
{ test: /icon_.+\.(svg)$/i,
loader: "url-loader",
},
{test: /\.html$/, loader: 'html-loader'},
]
},
plugins: [
new HtmlWebpackPlugin({
template: './src/index.html'
}),
new HtmlWebpackPlugin({ // Also generate a test.html
filename: 'product.html',
template: 'src/product.html'
}),
new ExtractTextPlugin("styles_[hash].css"),
new CopyWebpackPlugin([
{from: './src/assets', to: 'assets'}
])
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment