Created
August 2, 2018 06:22
-
-
Save awareness481/9e42cf7938074c8db88823b27a0d11cd to your computer and use it in GitHub Desktop.
This file contains 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 CopyWebpackPlugin = require('copy-webpack-plugin') | |
module.exports = { | |
entry: './src/app.js', | |
target: 'web', | |
node: { | |
fs: 'empty' | |
}, | |
output: { | |
path: path.join(__dirname, 'public'), | |
filename: 'bundle.js', | |
publicPath: '/public/' | |
}, | |
module: { | |
rules: [{ | |
test: /\.js$/, | |
include: path.join(__dirname, 'src'), | |
exclude: [ /(node_modules|bower_components)/, | |
'./src/server.js', | |
'./src/srv-compiled.js' | |
], | |
use: { | |
loader: 'babel-loader', | |
options: { | |
presets: ['env'] | |
} | |
} | |
},] | |
}, | |
module: { | |
rules: [{ | |
test: /\.scss$/, | |
use: [ | |
"style-loader", // creates style nodes from JS strings | |
"css-loader", // translates CSS into CommonJS | |
"sass-loader" // compiles Sass to CSS | |
], | |
}] | |
}, | |
plugins: [ | |
new CopyWebpackPlugin([{ | |
test: /\.(png|jpg|gif)$/, | |
from: 'assets/', to: 'public' | |
} | |
]), | |
] | |
} |
This file contains 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 webpack = require('webpack'); | |
const merge = require('webpack-merge'); | |
const common = require('./webpack.common.js'); | |
const MiniCssExtractPlugin = require("mini-css-extract-plugin"); | |
const OptimizeCSSAssetsPlugin = require("optimize-css-assets-webpack-plugin"); | |
const UglifyJsPlugin = require('uglifyjs-webpack-plugin'); | |
module.exports = merge(common, { | |
mode: 'production', | |
optimization: { | |
minimizer: [ | |
new UglifyJsPlugin({ | |
cache: true, | |
parallel: true | |
}), | |
new OptimizeCSSAssetsPlugin({}) | |
] | |
}, | |
plugins: [ | |
new MiniCssExtractPlugin({ | |
filename: "[name].css", | |
chunkFilename: "[id].css" | |
}), | |
], | |
module: { | |
rules: [ | |
{ | |
test: /\.(sa|sc|c)ss$/, | |
use: [ | |
MiniCssExtractPlugin.loader, | |
'css-loader', | |
'sass-loader', | |
], | |
} | |
] | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment