Skip to content

Instantly share code, notes, and snippets.

@hayeah
Created December 30, 2015 02:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hayeah/555635d10fa7f4bd1c62 to your computer and use it in GitHub Desktop.
Save hayeah/555635d10fa7f4bd1c62 to your computer and use it in GitHub Desktop.
webpack example
var path = require("path");
var ExtractTextPlugin = require("extract-text-webpack-plugin");
module.exports = {
// The standard entry point and output config
entry: {
static: "./assets/static.js",
},
output: {
path: path.join(__dirname,"src","assets"),
// publicPath: "/assets/",
filename: "[name].js",
},
module: {
loaders: [
// Extract css files
{
test: /\.css$/,
loader: ExtractTextPlugin.extract("style-loader", "css-loader")
},
{
test: /\.scss$/,
loader: ExtractTextPlugin.extract("style-loader", "css-loader!sass-loader")
},
{
test: /\.jsx?$/,
loader: "babel-loader?stage=0",
exclude: /node_modules/,
},
// font-awesome
// https://gist.github.com/Turbo87/e8e941e68308d3b40ef6
{
test: /\.woff(\?v=\d+\.\d+\.\d+)?$/,
loader: "url?limit=10000&mimetype=application/font-woff"
}, {
test: /\.woff2(\?v=\d+\.\d+\.\d+)?$/,
loader: "url?limit=10000&mimetype=application/font-woff"
}, {
test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/,
loader: "url?limit=10000&mimetype=application/octet-stream"
}, {
test: /\.eot(\?v=\d+\.\d+\.\d+)?$/,
loader: "file"
}, {
test: /\.svg(\?v=\d+\.\d+\.\d+)?$/,
loader: "url?limit=10000&mimetype=image/svg+xml"
}
// Optionally extract less files
// or any other compile-to-css language
// {
// test: /\.less$/,
// loader: ExtractTextPlugin.extract("style-loader", "css-loader!less-loader")
// }
// You could also use other loaders the same way. I. e. the autoprefixer-loader
]
},
// Use the plugin to specify the resulting filename (and add needed behavior to the compiler)
plugins: [
new ExtractTextPlugin("[name].css")
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment