ampache_react/webpack.config.base.js

123 lines
3.7 KiB
JavaScript
Raw Normal View History

2016-07-07 23:23:18 +02:00
var path = require("path");
var webpack = require("webpack");
var CopyWebpackPlugin = require('copy-webpack-plugin');
var ExtractTextPlugin = require("extract-text-webpack-plugin");
2016-07-25 23:22:44 +02:00
var postcssReporter = require("postcss-reporter");
var autoprefixer = require("autoprefixer");
2016-07-25 23:22:44 +02:00
var browsers = ["ie >= 9", "> 1%", "last 3 versions", "not op_mini all"];
2016-07-07 23:23:18 +02:00
module.exports = {
entry: {
2016-07-30 22:54:19 +02:00
"index": [
"babel-polyfill",
"bootstrap-loader",
"font-awesome-webpack",
// Add global style hacks
"./app/common/styles/index.js",
// Add utils in entry for prototypes modification
"./app/common/utils/index.js",
// Main entry point
2016-07-30 22:54:19 +02:00
"./index.js"],
2016-07-07 23:23:18 +02:00
"fix.ie9": "./fix.ie9.js"
},
output: {
path: path.join(__dirname, "public/"),
2016-07-07 23:23:18 +02:00
filename: "[name].js",
2016-07-26 21:01:27 +02:00
publicPath: "./"
2016-07-07 23:23:18 +02:00
},
module: {
loaders: [
// Handle JS/JSX files
2016-07-07 23:23:18 +02:00
{
test: /\.jsx?$/,
exclude: /node_modules/,
loader: "babel",
query: {
"cacheDirectory": ".cache/"
},
2016-07-07 23:23:18 +02:00
include: __dirname
},
// Handle CSS files
{
test: /\.css$/,
loader: ExtractTextPlugin.extract(
"style-loader",
"css-loader?modules&importLoaders=1&localIdentName=[name]__[local]__[hash:base64:5]" +
"!postcss-loader"
)
},
// Handle SASS files
{
test: /\.scss$/,
loader: ExtractTextPlugin.extract(
"style-loader",
"css-loader?modules&importLoaders=1&localIdentName=[name]__[local]__[hash:base64:5]" +
"!postcss-loader" +
2016-07-31 12:18:46 +02:00
"!sass-loader" +
"!sass-resources-loader"
)
},
// Fonts
{
test: /\.eot(\?v=\d+\.\d+\.\d+)?$/,
loader: "file"
},
{
test: /\.woff(2)?(\?v=[0-9]\.[0-9]\.[0-9])?$/,
loader: "url-loader?limit=10000&minetype=application/font-woff"
},
{
test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/,
loader: "url?limit=10000&mimetype=application/octet-stream"
},
// SVG
{
test: /\.svg(\?v=\d+\.\d+\.\d+)?$/,
loader: "url?limit=10000&mimetype=image/svg+xml"
2016-07-07 23:23:18 +02:00
}
]
},
plugins: [
// Copy some useful files to the output path
new CopyWebpackPlugin([
{ from: "./index.html" },
{ from: "./favicon.ico" },
{ from: "./app/assets" },
{ from: "./app/vendor" }
]),
// Provide jQuery
new webpack.ProvidePlugin({
$: "jquery",
jQuery: "jquery"
}),
// Extract CSS
new ExtractTextPlugin("style.css", { allChunks: true })
2016-07-07 23:23:18 +02:00
],
// PostCSS config
postcss: [
autoprefixer({ browsers: browsers }),
postcssReporter({ throwError: true, clearMessages: true })
],
2016-07-31 12:18:46 +02:00
sassResources: "./app/styles/variables.scss",
2016-07-07 23:23:18 +02:00
resolve: {
// Include empty string "" to resolve files by their explicit extension
// (e.g. require("./somefile.ext")).
// Include ".js", ".jsx" to resolve files by these implicit extensions
// (e.g. require("underscore")).
extensions: ["", ".js", ".jsx"],
// Hack for isotope
alias: {
"masonry": "masonry-layout",
"isotope": "isotope-layout"
},
2016-07-07 23:23:18 +02:00
}
};