Created
December 5, 2016 16:28
-
-
Save syon/a1a7574c4dac6040af63a6aa4bf830ce to your computer and use it in GitHub Desktop.
SPA ではない Webpack 設定サンプル
This file contains hidden or 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 HtmlWebpackPlugin = require('html-webpack-plugin'); | |
module.exports = { | |
context: __dirname + '/src', | |
entry: { | |
javascript: './app.js', | |
}, | |
output: { | |
path: __dirname + '/www', | |
filename: 'bundle.js' | |
}, | |
devServer: { | |
contentBase: 'www', | |
port: 3000 | |
}, | |
devtool: 'source-map', | |
module: { | |
loaders: [ | |
{ | |
// https://github.com/babel/babel-loader | |
test: /\.js$/, | |
exclude: /node_modules/, | |
loader: 'babel-loader', | |
query:{ | |
presets: ['es2015'] | |
} | |
}, | |
{ | |
test: /\.css$/, | |
loader: 'style-loader!css-loader!postcss-loader' | |
}, | |
{ | |
test: /\.pug$/, | |
loader: 'pug-loader' | |
}, | |
// Bootstrap - https://github.com/shakacode/bootstrap-loader#jquery | |
// FontAwesome - https://gist.github.com/Turbo87/e8e941e68308d3b40ef6 | |
{ test: /bootstrap-sass[\/\\]assets[\/\\]javascripts[\/\\]/, loader: 'imports-loader?jQuery=jquery' }, | |
{ test: /\.(woff2?|svg)(\?v=\d+\.\d+\.\d+)?$/, loader: 'url-loader?limit=10000' }, | |
{ test: /\.(ttf|eot)(\?v=\d+\.\d+\.\d+)?$/, loader: 'file-loader' }, | |
{ | |
test: /\.(jpg|png)$/, | |
loader: 'url-loader' | |
} | |
] | |
}, | |
plugins: [ | |
new HtmlWebpackPlugin({ | |
title: 'AWAKE', | |
template: 'index.pug' | |
}), | |
new HtmlWebpackPlugin({ | |
filename: 'hello.html', | |
template: 'hello.pug' | |
}), | |
new HtmlWebpackPlugin({ | |
filename: 'world.html', | |
template: 'world.pug' | |
}) | |
], | |
postcss: function() { | |
var precss = require('precss'); | |
var autoprefixer = require('autoprefixer'); | |
return [ | |
autoprefixer({ browsers: ['IE 9', 'IE 10', 'IE 11', 'last 2 versions'] }), | |
precss | |
]; | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment