Created
July 25, 2017 04:17
-
-
Save astrotim/41309ae5769862795bcd07588711cf1a to your computer and use it in GitHub Desktop.
Builds site as static files using StaticSiteGeneratorPlugin
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
const path = require('path'); | |
const webpack = require('webpack'); | |
const CopyWebpackPlugin = require('copy-webpack-plugin'); | |
const ExtractTextPlugin = require('extract-text-webpack-plugin'); | |
const StaticSiteGeneratorPlugin = require('static-site-generator-webpack-plugin'); | |
module.exports = { | |
entry: [path.resolve(__dirname, 'src')], | |
output: { | |
path: path.resolve(__dirname, 'dist'), | |
filename: 'bundle.js', | |
libraryTarget: 'umd' | |
}, | |
plugins: [ | |
new ExtractTextPlugin('style.css'), | |
new StaticSiteGeneratorPlugin({ | |
crawl: true, | |
paths: ['/'] | |
}), | |
new CopyWebpackPlugin([ | |
{ | |
from: path.resolve(__dirname, 'src', 'favicon.ico'), | |
to: path.resolve(__dirname, 'dist') | |
} | |
]) | |
], | |
module: { | |
rules: [ | |
{ | |
test: /\.js$/, | |
include: [path.resolve(__dirname, 'src')], | |
use: { | |
loader: 'babel-loader', | |
options: { | |
presets: ['react', 'es2015'] | |
} | |
} | |
}, | |
{ | |
test: /\.(css|scss)$/, | |
loader: ExtractTextPlugin.extract({ | |
fallback: 'style-loader', | |
use: [ | |
{ | |
loader: 'css-loader', | |
options: { | |
modules: true, | |
camelCase: true, | |
localIdentName: '[name]__[local]--[hash:base64:5]' | |
} | |
}, | |
{ | |
loader: 'postcss-loader', | |
options: { | |
plugins: [require('autoprefixer')] | |
} | |
}, | |
{ | |
loader: 'sass-loader' | |
} | |
] | |
}) | |
} | |
] | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment