2016-07-28 17:56:13 +00:00
|
|
|
const webpack = require('webpack');
|
|
|
|
const fs = require('fs');
|
|
|
|
const path = require('path');
|
|
|
|
const autoprefixer = require('autoprefixer');
|
|
|
|
const precss = require('precss');
|
|
|
|
const HtmlWebPackPlugin = require('html-webpack-plugin');
|
2017-04-29 22:51:25 +00:00
|
|
|
const SWPrecacheWebpackPlugin = require('sw-precache-webpack-plugin');
|
2016-07-28 17:56:13 +00:00
|
|
|
|
2016-07-27 17:13:08 +00:00
|
|
|
module.exports = {
|
2017-04-29 22:51:25 +00:00
|
|
|
context: __dirname,
|
2016-07-27 17:13:08 +00:00
|
|
|
devtool: 'cheap-module-source-map',
|
|
|
|
entry: [
|
|
|
|
'./src/index'
|
|
|
|
],
|
|
|
|
output: {
|
|
|
|
path: path.resolve(__dirname, './dist'),
|
|
|
|
publicPath: './dist/',
|
|
|
|
filename: 'bundle.js'
|
|
|
|
},
|
|
|
|
resolve: {
|
2017-03-18 12:58:55 +00:00
|
|
|
extensions: ['.js', '.jsx']
|
2016-07-27 17:13:08 +00:00
|
|
|
},
|
|
|
|
plugins: [
|
|
|
|
new HtmlWebPackPlugin({
|
|
|
|
template: 'src/index.html',
|
|
|
|
filename: '../index.html'
|
|
|
|
}),
|
|
|
|
new webpack.optimize.UglifyJsPlugin({
|
2017-03-18 12:58:55 +00:00
|
|
|
sourceMap: true,
|
2016-07-27 17:13:08 +00:00
|
|
|
compress:{
|
|
|
|
warnings: false
|
|
|
|
},
|
|
|
|
}),
|
2017-03-18 12:58:55 +00:00
|
|
|
new webpack.NoEmitOnErrorsPlugin(),
|
|
|
|
new webpack.LoaderOptionsPlugin({
|
|
|
|
options: {
|
|
|
|
postcss: function() {
|
|
|
|
return [autoprefixer, precss];
|
|
|
|
}
|
|
|
|
}
|
2017-04-29 22:51:25 +00:00
|
|
|
}),
|
|
|
|
new SWPrecacheWebpackPlugin( {
|
|
|
|
cacheId: 'kana-quiz',
|
|
|
|
filename: 'sw.js',
|
2018-10-02 18:24:32 +00:00
|
|
|
stripPrefix: '/home/anzz/Code/kanaquiz/',
|
2017-04-29 22:51:25 +00:00
|
|
|
maximumFileSizeToCacheInBytes: 4194304,
|
|
|
|
minify: true,
|
|
|
|
runtimeCaching: [{
|
2018-10-02 18:24:32 +00:00
|
|
|
handler: 'networkFirst',
|
2017-04-29 22:51:25 +00:00
|
|
|
urlPattern: /\.(woff2|svg|ttf|eot|woff|html)$/,
|
|
|
|
}],
|
|
|
|
})
|
2016-07-27 17:13:08 +00:00
|
|
|
],
|
|
|
|
module: {
|
|
|
|
loaders: [
|
|
|
|
{
|
|
|
|
test: /\.jsx?$/,
|
|
|
|
exclude: /node_modules/,
|
2017-03-18 12:58:55 +00:00
|
|
|
loaders: ['babel-loader']
|
2016-07-27 17:13:08 +00:00
|
|
|
}, {
|
|
|
|
test: /\.scss$/,
|
|
|
|
loaders: ['style-loader', 'css-loader', 'postcss-loader']
|
|
|
|
}, {
|
|
|
|
test: /\.css$/,
|
|
|
|
loaders: ['style-loader', 'css-loader']
|
2017-03-18 12:58:55 +00:00
|
|
|
}, {
|
2017-04-29 22:51:25 +00:00
|
|
|
test: /\.(png|jpg|svg|woff|woff2)?(\?v=\d+.\d+.\d+)?$/,
|
2016-07-27 17:13:08 +00:00
|
|
|
loader: 'url-loader?limit=8192'
|
2017-03-18 12:58:55 +00:00
|
|
|
}, {
|
2017-04-29 22:51:25 +00:00
|
|
|
test: /\.(eot|ttf)$/,
|
2016-07-27 17:13:08 +00:00
|
|
|
loader: 'file-loader'
|
2017-04-29 22:51:25 +00:00
|
|
|
}
|
2016-07-27 17:13:08 +00:00
|
|
|
]
|
|
|
|
}
|
2018-10-02 18:24:32 +00:00
|
|
|
};
|