77 lines
1.9 KiB
JavaScript
77 lines
1.9 KiB
JavaScript
|
const webpack = require('webpack');
|
||
|
const convert = require('koa-connect');
|
||
|
const history = require('connect-history-api-fallback');
|
||
|
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
||
|
const HtmlWebpackInlineSourcePlugin = require('html-webpack-inline-source-plugin');
|
||
|
const ScriptExtHtmlWebpackPlugin = require('script-ext-html-webpack-plugin');
|
||
|
const commonPaths = require('./paths');
|
||
|
|
||
|
module.exports = {
|
||
|
entry: commonPaths.entryPath,
|
||
|
module: {
|
||
|
rules: [
|
||
|
{
|
||
|
enforce: 'pre',
|
||
|
test: /\.(js|jsx)$/,
|
||
|
loader: 'eslint-loader',
|
||
|
exclude: /(node_modules)/,
|
||
|
options: {
|
||
|
emitWarning: process.env.NODE_ENV !== 'production',
|
||
|
},
|
||
|
},
|
||
|
{
|
||
|
test: /\.(js|jsx)$/,
|
||
|
loader: 'babel-loader',
|
||
|
exclude: /(node_modules)/,
|
||
|
},
|
||
|
{
|
||
|
test: /\.(png|jpg|gif|svg)$/,
|
||
|
use: [
|
||
|
{
|
||
|
loader: 'file-loader',
|
||
|
options: {
|
||
|
outputPath: commonPaths.imagesFolder,
|
||
|
},
|
||
|
},
|
||
|
],
|
||
|
},
|
||
|
{
|
||
|
test: /\.(woff2|ttf|woff|eot)$/,
|
||
|
use: [
|
||
|
{
|
||
|
loader: 'file-loader',
|
||
|
options: {
|
||
|
outputPath: commonPaths.fontsFolder,
|
||
|
},
|
||
|
},
|
||
|
],
|
||
|
},
|
||
|
],
|
||
|
},
|
||
|
serve: {
|
||
|
add: app => {
|
||
|
app.use(convert(history()));
|
||
|
},
|
||
|
content: commonPaths.entryPath,
|
||
|
dev: {
|
||
|
publicPath: commonPaths.outputPath,
|
||
|
},
|
||
|
open: true,
|
||
|
},
|
||
|
resolve: {
|
||
|
modules: ['src', 'node_modules'],
|
||
|
extensions: ['*', '.js', '.jsx', '.css', '.scss'],
|
||
|
},
|
||
|
plugins: [
|
||
|
new webpack.ProgressPlugin(),
|
||
|
new HtmlWebpackPlugin({
|
||
|
template: commonPaths.templatePath,
|
||
|
inlineSource: '.(js|css)$' // embed all javascript and css inline
|
||
|
}),
|
||
|
new ScriptExtHtmlWebpackPlugin({
|
||
|
defaultAttribute: 'async',
|
||
|
}),
|
||
|
new HtmlWebpackInlineSourcePlugin(),
|
||
|
],
|
||
|
};
|