sportstg-bluekit
Version:

89 lines (88 loc) • 2.66 kB
JavaScript
const path = require('path');
const webpack = require('webpack');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const pkg = require('./package.json')
const appBuild = path.join(__dirname, 'index.html')
const publicPath = '/';
const packageName = pkg.name
module.exports = {
devtool: 'eval',
entry: [
'webpack-dev-server/client?http://localhost:3000',
'webpack/hot/only-dev-server',
'./src/index'
],
output: {
// Next line is not used in dev but WebpackDevServer crashes without it:
path: appBuild,
// Add /* filename */ comments to generated require()s in the output.
pathinfo: true,
// This does not produce a real file. It's just the virtual path that is
// served by WebpackDevServer in development. This is the JS bundle
// containing code from all our entry points, and the Webpack runtime.
filename: `static/js/${packageName}.js`,
// There are also additional JS chunk files if you use code splitting.
chunkFilename: `static/js/${packageName}.chunk.js`,
// This is the URL that app is served from. We use "/" in development.
publicPath: publicPath,
},
plugins: [
new ExtractTextPlugin({ // define where to save the file
filename: `static/css/${packageName}.css`,
allChunks: true,
}),
// Generates an `index.html` file with the <script> injected.
new HtmlWebpackPlugin({
inject: true,
template: appBuild,
}),
new webpack.HotModuleReplacementPlugin()
],
module: {
rules: [
{
test: /(\.css|\.scss)$/,
exclude: /node_modules/,
use: ['css-hot-loader'].concat(ExtractTextPlugin.extract({
fallback: 'style-loader',
use: [
{
loader: 'css-loader',
query: {
modules: true,
sourceMap: true,
importLoaders: 2,
localIdentName: '[name]__[local]___[hash:base64:5]'
}
},
{
loader : 'sass-loader',
options: {
sourceMap: true
}
},
{
loader : 'postcss-loader',
options: {
plugins: function () {
return [
require('autoprefixer')
];
}
}
}
]
})),
},
{
test: /\.js$/,
enforce: 'pre',
loaders: ['babel-loader'],
include: [
path.join(__dirname, 'src'),
]
},
]
}
};