Created
January 4, 2019 02:13
-
-
Save sleepiecappy/4a689327637e645717c93713cd692a29 to your computer and use it in GitHub Desktop.
phoenix webapck
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const path = require('path'); | |
const glob = require('glob'); | |
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 paths = { | |
static: path.join(__dirname, "../priv/static"), | |
build: path.join(__dirname, "../priv/static"), | |
node_modules: path.join(__dirname, "./node_modules"), | |
src: path.join(__dirname, "./"), | |
} | |
const webpackConfig = { | |
context: process.cwd(), | |
entry: { | |
'app': [path.join(paths.src, "js/app.js")], | |
'css': path.join(paths.src, "scss/app.scss"), | |
}, | |
output: { | |
path: paths.build, | |
filename: "js/[name].js", | |
}, | |
resolve: { | |
extensions: [".js", ".jsx"], | |
symlinks: false, | |
}, | |
plugins: [ | |
new MiniCssExtractPlugin({ | |
filename: "css/app.css", | |
}), | |
new CopyWebpackPlugin([ | |
{ | |
from: path.join(paths.src, 'static'), | |
to: paths.static | |
} | |
]) | |
], | |
module: { | |
rules: [ | |
{ | |
test: /\.js$/, | |
exclude: /(node_modules)/, | |
use: { | |
loader: "babel-loader", | |
}, | |
}, | |
{ | |
test: /\.scss$/, | |
use: [ | |
{ | |
loader: MiniCssExtractPlugin.loader, | |
}, | |
"css-loader?importLoaders=1&minimize&sourceMap&-autoprefixer", | |
"postcss-loader", | |
"sass-loader", | |
], | |
}, | |
], | |
}, | |
devServer: { | |
publicPath: "/", | |
}, | |
}; | |
module.exports = webpackConfig; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment