Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/jacobsun/edidor.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'webpack.config.js')
-rw-r--r--webpack.config.js67
1 files changed, 67 insertions, 0 deletions
diff --git a/webpack.config.js b/webpack.config.js
new file mode 100644
index 0000000..8fa7ed6
--- /dev/null
+++ b/webpack.config.js
@@ -0,0 +1,67 @@
+const path = require('path')
+
+const MiniCssExtractPlugin = require('mini-css-extract-plugin')
+const TerserJSPlugin = require('terser-webpack-plugin')
+const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin')
+const postcssPresetEnv = require('postcss-preset-env')
+
+let config = {
+ mode: process.env.NODE_ENV,
+ entry: path.resolve(__dirname, 'src/index.js'),
+ output: {
+ path: path.resolve(__dirname, 'static'),
+ filename: 'js/[name].js'
+ },
+ module: {
+ rules: [
+ {
+ test: /\.(png|jpe?g|gif|svg|eot|ttf|woff|woff2)$/,
+ use: [{
+ loader: 'url-loader',
+ options: {
+ limit: 8000,
+ fallback: {
+ loader: 'file-loader',
+ options: {
+ name: '/images/[name].[ext]'
+ }
+ }
+ }
+ }]
+ },
+ {
+ test: /\.scss$/,
+ use: [
+ MiniCssExtractPlugin.loader,
+ { loader: 'css-loader', options: { importLoaders: 1 } },
+ {
+ loader: 'postcss-loader',
+ options: {
+ ident: 'postcss',
+ plugins: () => [
+ postcssPresetEnv({
+ autoprefixer: {}
+ })
+ ]
+ }
+ },
+ 'sass-loader'
+ ]
+ }
+ ]
+ },
+ optimization: {
+ minimizer: [
+ new TerserJSPlugin({}),
+ new OptimizeCSSAssetsPlugin({})
+ ]
+ },
+ plugins: [
+ new MiniCssExtractPlugin({
+ filename: 'css/[name].css',
+ chunkFilename: '[id].css'
+ })
+ ],
+ devtool: process.env.NODE_ENV === 'production' ? false : 'eval'
+}
+module.exports = config