Bootstrap 4
{
“repository”: {},
“license”: “MIT”,
“scripts”: {
“deploy”: “webpack --mode production --progress”,
“watch”: “webpack --watch-stdin --progress --color”
},
“dependencies”: {
“animate.css”: “^3.5.2”,
“bootstrap”: “4.0.0-alpha.6”,
“bootswatch”: “https://github.com:/thomaspark/bootswatch.git#v4.0.0-beta.2”,
“phoenix”: “file:…/…/…/deps/phoenix”,
“phoenix_html”: “file:…/…/…/deps/phoenix_html”
},
“devDependencies”: {
“babel-core”: “^6.26.0”,
“babel-loader”: “^7.1.3”,
“babel-preset-env”: “^1.6.1”,
“copy-webpack-plugin”: “^4.5.0”,
“css-loader”: “^0.28.10”,
“exports-loader”: “^0.7.0”,
“file-loader”: “^1.1.11”,
“mini-css-extract-plugin”: “^0.4.0”,
“node-sass”: “^4.9.0”,
“optimize-css-assets-webpack-plugin”: “^4.0.0”,
“postcss-loader”: “^2.1.5”,
“sass-loader”: “^7.0.1”,
“style-loader”: “^0.21.0”,
“uglifyjs-webpack-plugin”: “^1.2.4”,
“webpack”: “4.4.0”,
“webpack-cli”: “^2.0.10”
}
}
const path = require(‘path’);
const MiniCssExtractPlugin = require(‘mini-css-extract-plugin’);
const UglifyJsPlugin = require(‘uglifyjs-webpack-plugin’);
const OptimizeCSSAssetsPlugin = require(‘optimize-css-assets-webpack-plugin’);
const CopyWebpackPlugin = require(‘copy-webpack-plugin’);
const webpack = require(“webpack”);
const staticDir = path.join(__dirname, ‘.’);
const destDir = path.join(__dirname, ‘…/priv/static’);
const publicPath = ‘/’;
module.exports = (env, options) => ({
entry: {
app: [
staticDir + “/css/animate.css”,
staticDir + “/js/app.js”,
staticDir + “/js/bootstrap/alert.js”,
staticDir + “/js/bootstrap/button.js”,
staticDir + “/js/bootstrap/carousel.js”,
staticDir + “/js/bootstrap/collapse.js”,
staticDir + “/js/bootstrap/dropdown.js”,
staticDir + “/js/bootstrap/modal.js”,
staticDir + “/js/bootstrap/popover.js”,
staticDir + “/js/bootstrap/scrollspy.js”,
staticDir + “/js/bootstrap/tab.js”,
staticDir + “/js/bootstrap/tooltip.js”,
staticDir + “/js/bootstrap/util.js”]
},
output: {
path: destDir,
filename: “js/[name].js”,
publicPath
},
module: {
rules: [
{
test: /.js$/,
exclude: /node_modules/,
use: {
loader: ‘babel-loader’
}
},
// Adds font implications
{
test: /.(css|scss|sass)/,
use: [ ‘style-loader’, MiniCssExtractPlugin.loader, ‘css-loader’, ‘sass-loader’]
},
{
test: /.(eot|svg|ttf|woff|woff2)(?\S*)?$/,
loader: “file-loader”
},
{
test: /.(png|jpe?g|gif|svg)(?\S*)?$/,
loader: “file-loader”,
query: {
name: “[name].[ext]?[hash]”
}
}
]
},
plugins: [
new MiniCssExtractPlugin({ filename: ‘./css/app.css’ }),
new CopyWebpackPlugin([{ from: “./static” }]),
new webpack.ProvidePlugin({
$: “jquery”,
jQuery: “jquery”,
“window.jQuery”: “jquery”,
Tether: “tether”,
“window.Tether”: “tether”,
Alert: “exports-loader?Alert!bootstrap/js/dist/alert”,
Button: “exports-loader?Button!bootstrap/js/dist/button”,
Carousel: “exports-loader?Carousel!bootstrap/js/dist/carousel”,
Collapse: “exports-loader?Collapse!bootstrap/js/dist/collapse”,
Dropdown: “exports-loader?Dropdown!bootstrap/js/dist/dropdown”,
Modal: “exports-loader?Modal!bootstrap/js/dist/modal”,
Popover: “exports-loader?Popover!bootstrap/js/dist/popover”,
Scrollspy: “exports-loader?Scrollspy!bootstrap/js/dist/scrollspy”,
Tab: “exports-loader?Tab!bootstrap/js/dist/tab”,
Tooltip: “exports-loader?Tooltip!bootstrap/js/dist/tooltip”,
Util: “exports-loader?Util!bootstrap/js/dist/util”,
}),
]
});
if (process.env.NODE_ENV === “production”) {
module.exports.devtool = “#cheap-module-eval-source-map”;
module.exports.plugins = (module.exports.plugins || ).concat([
new webpack.DefinePlugin({
“process.env”: {
NODE_ENV: “‘production’”
}
}),
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false
}
}),
new OptimizeCssAssetsPlugin()
]);
}