2016-10-17 22:00:29 +13:00
|
|
|
|
2017-03-08 09:13:24 +13:00
|
|
|
const isDev = process.env.NODE_ENV !== "production";
|
|
|
|
|
const path = require('path');
|
|
|
|
|
const webpack = require('webpack');
|
2019-04-12 09:59:37 +12:00
|
|
|
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
2016-10-03 14:44:27 +13:00
|
|
|
|
2017-03-08 09:13:24 +13:00
|
|
|
const config = {
|
2019-04-12 09:59:37 +12:00
|
|
|
mode: process.env.NODE_ENV,
|
2017-03-08 09:13:24 +13:00
|
|
|
context: path.resolve(__dirname),
|
|
|
|
|
entry: {
|
|
|
|
|
js: './src/js/index'
|
|
|
|
|
},
|
2016-10-03 14:44:27 +13:00
|
|
|
output: {
|
2019-04-12 09:59:37 +12:00
|
|
|
path: path.resolve(__dirname, 'mopidy_iris/static/app'),
|
|
|
|
|
filename: 'app'+(isDev ? '' : '.min')+'.js'
|
2016-10-03 14:44:27 +13:00
|
|
|
},
|
|
|
|
|
module: {
|
2017-03-08 09:13:24 +13:00
|
|
|
rules: [
|
2016-10-17 22:00:29 +13:00
|
|
|
{
|
2017-03-08 09:13:24 +13:00
|
|
|
test: require.resolve('jquery'),
|
|
|
|
|
exclude: [
|
|
|
|
|
/node_modules/
|
|
|
|
|
],
|
2019-04-12 09:59:37 +12:00
|
|
|
use: [
|
|
|
|
|
'expose-loader?jQuery!expose?$'
|
|
|
|
|
]
|
2016-10-17 22:00:29 +13:00
|
|
|
},
|
2016-10-03 14:44:27 +13:00
|
|
|
{
|
|
|
|
|
test: /\.js$/,
|
2019-04-12 09:59:37 +12:00
|
|
|
exclude: /node_modules/,
|
|
|
|
|
use: [
|
|
|
|
|
{
|
|
|
|
|
loader: 'babel-loader',
|
|
|
|
|
options: {
|
|
|
|
|
presets: [
|
|
|
|
|
'react',
|
|
|
|
|
'es2015',
|
|
|
|
|
'stage-2'
|
|
|
|
|
]
|
|
|
|
|
}
|
2017-03-08 09:13:24 +13:00
|
|
|
}
|
2019-04-12 09:59:37 +12:00
|
|
|
]
|
2016-10-03 14:44:27 +13:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
test: /\.scss$/,
|
2019-04-12 09:59:37 +12:00
|
|
|
use: [
|
|
|
|
|
{
|
|
|
|
|
loader: MiniCssExtractPlugin.loader,
|
|
|
|
|
options: {
|
|
|
|
|
publicPath: './',
|
|
|
|
|
hmr: process.env.NODE_ENV === 'development',
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
'css-loader',
|
|
|
|
|
'sass-loader',
|
|
|
|
|
]
|
2016-10-17 22:00:29 +13:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
// load external resources (ie Google fonts)
|
2016-12-18 11:32:03 +13:00
|
|
|
test: /.(gif|png|woff(2)?|eot|ttf|svg)(\?[a-z0-9=\.]+)?$/,
|
2019-04-12 09:59:37 +12:00
|
|
|
use: [
|
|
|
|
|
{
|
|
|
|
|
loader: 'url-loader',
|
|
|
|
|
options: {
|
|
|
|
|
name: '[name].[ext]?[hash]',
|
|
|
|
|
limit: 100000
|
|
|
|
|
}
|
2017-03-08 09:13:24 +13:00
|
|
|
}
|
2019-04-12 09:59:37 +12:00
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
(isDev ? {} : {
|
|
|
|
|
test: /\.(js)$/,
|
|
|
|
|
use: [
|
|
|
|
|
{
|
|
|
|
|
loader: 'webpack-strip',
|
|
|
|
|
options: {
|
|
|
|
|
strip: [
|
|
|
|
|
'console.log',
|
|
|
|
|
'console.info',
|
|
|
|
|
'debug'
|
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
})
|
2016-10-03 14:44:27 +13:00
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
plugins: [
|
|
|
|
|
new webpack.ProvidePlugin({
|
|
|
|
|
$: "jquery",
|
|
|
|
|
jQuery: "jquery",
|
|
|
|
|
"window.jQuery": "jquery"
|
2019-04-12 09:59:37 +12:00
|
|
|
}),
|
|
|
|
|
new MiniCssExtractPlugin({
|
|
|
|
|
filename: 'app'+(isDev ? '' : '.min')+'.css',
|
|
|
|
|
}),
|
|
|
|
|
],
|
|
|
|
|
watchOptions: {
|
|
|
|
|
poll: true
|
|
|
|
|
},
|
|
|
|
|
devtool: (isDev ? 'source-map': false)
|
2016-10-03 14:44:27 +13:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Development-only configuration values
|
|
|
|
|
**/
|
2017-03-08 09:13:24 +13:00
|
|
|
if (isDev){
|
2016-10-03 14:44:27 +13:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Production-only configuration values
|
|
|
|
|
**/
|
2017-03-08 09:13:24 +13:00
|
|
|
} else {
|
2016-10-03 14:44:27 +13:00
|
|
|
|
|
|
|
|
// re-iterate our production value as a string (for ReactJS building)
|
|
|
|
|
config.plugins.push(
|
|
|
|
|
new webpack.DefinePlugin({
|
|
|
|
|
'process.env':{
|
|
|
|
|
'NODE_ENV': JSON.stringify('production')
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// now export our collated config object
|
|
|
|
|
module.exports = config;
|