Skip to content

Instantly share code, notes, and snippets.

@praveenperera
Created April 26, 2017 20:22
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save praveenperera/50e23ac9b00b9ae67321181189798b6d to your computer and use it in GitHub Desktop.
Save praveenperera/50e23ac9b00b9ae67321181189798b6d to your computer and use it in GitHub Desktop.
Webpack Multiple Entry Points
import webpack from "webpack";
import ExtractTextPlugin from "extract-text-webpack-plugin";
import CopyWebpackPlugin from "copy-webpack-plugin";
import WebpackNotifierPlugin from "webpack-notifier";
const commonCss = `${__dirname}/web/static/css/common`;
const extractSass = new ExtractTextPlugin({
filename: "css/[name].css",
});
export default {
entry: {
app: ["./web/static/css/app/app.scss", "./web/static/js/app.js"],
support: [
"./web/static/css/support/support.scss",
"./web/static/js/support.js",
],
},
output: {
path: `${__dirname}/priv/static`,
filename: "./js/[name].js",
publicPath: "/",
},
resolve: {
modules: ["node_modules", `${__dirname}/web/static/js`],
},
module: {
loaders: [
{
test: /\.js$/,
exclude: /node_modules/,
loader: "babel-loader",
include: __dirname,
},
{
test: /\.css$/,
use: [
"style-loader",
{
loader: "css-loader",
options: {
includePaths: [`${__dirname}/node_modules`, commonCss],
sourceMap: true,
},
},
],
},
{
test: /\.scss$/,
use: extractSass.extract({
use: [
{
loader: "css-loader",
options: {
includePaths: [`${__dirname}/node_modules`, commonCss],
sourceMap: true,
},
},
"resolve-url-loader",
{
loader: "sass-loader",
options: {
includePaths: [`${__dirname}/node_modules`],
sourceMap: true,
},
},
],
fallback: "style-loader",
}),
},
{
test: /\.(eot|svg|ttf|woff|woff2)$/,
loader: "file-loader",
options: {
name: "[name].[ext]",
outputPath: "../static/fonts/",
publicPath: "../fonts/",
},
},
{
test: /\.(jpg|png|gif)$/,
loader: "file-loader",
options: {
name: "[name].[ext]",
outputPath: "../static/images/",
publicPath: "../images/",
},
},
],
},
plugins: [
new CopyWebpackPlugin([
{
from: `${__dirname}/web/static/assets`,
to: `${__dirname}/priv/static/`,
ignore: [".DS_Store"],
},
]),
new WebpackNotifierPlugin(),
new webpack.ProvidePlugin({
$: "jquery",
jQuery: "jquery",
"window.jQuery": "jquery",
}),
extractSass,
],
};
@praveenperera
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment