diff options
author | He Yeshuang <yeshuanghe@gmail.com> | 2020-03-29 16:30:26 +0300 |
---|---|---|
committer | He Yeshuang <yeshuanghe@gmail.com> | 2020-03-29 16:30:26 +0300 |
commit | ae31923d3169caea74aca2c630d87b6abc6086ce (patch) | |
tree | 56d2ea8f34ae0dc394a6743e96f92244bd704fe3 /webpack |
init from jimfrenette/hugo-starter
Diffstat (limited to 'webpack')
-rw-r--r-- | webpack/base.config.js | 35 | ||||
-rw-r--r-- | webpack/dev.config.js | 8 | ||||
-rw-r--r-- | webpack/prod.config.js | 18 |
3 files changed, 61 insertions, 0 deletions
diff --git a/webpack/base.config.js b/webpack/base.config.js new file mode 100644 index 0000000..1ae80a8 --- /dev/null +++ b/webpack/base.config.js @@ -0,0 +1,35 @@ +const path = require('path'); +const MiniCssExtractPlugin = require("mini-css-extract-plugin"); + +module.exports = { + context: path.resolve(__dirname, '../src'), + entry: { + app: ['./js/index.js'] + }, + plugins: [ + new MiniCssExtractPlugin + ], + output: { + path: path.resolve(__dirname, '../static/dist') + }, + module: { + rules: [ + { + test: /\.(css|scss)$/, + use: [ + MiniCssExtractPlugin.loader, + 'css-loader', + { + loader: 'postcss-loader' }, + { + loader: 'sass-loader' } + ] + }, + { + test: /\.js$/, + exclude: /node_modules/, + use: 'babel-loader' + } + ] + } +}
\ No newline at end of file diff --git a/webpack/dev.config.js b/webpack/dev.config.js new file mode 100644 index 0000000..9650e04 --- /dev/null +++ b/webpack/dev.config.js @@ -0,0 +1,8 @@ +const baseConfig = require('./base.config.js'); +const merge = require('webpack-merge'); + +module.exports = merge(baseConfig, { + mode: 'development', + devtool: 'eval-source-map', + watch: true +});
\ No newline at end of file diff --git a/webpack/prod.config.js b/webpack/prod.config.js new file mode 100644 index 0000000..4233037 --- /dev/null +++ b/webpack/prod.config.js @@ -0,0 +1,18 @@ +const baseConfig = require('./base.config.js'); +const merge = require('webpack-merge'); +const OptimizeCSSAssetsPlugin = require("optimize-css-assets-webpack-plugin"); +const UglifyJsPlugin = require("uglifyjs-webpack-plugin"); + +module.exports = merge(baseConfig, { + mode: 'production', + optimization: { + minimizer: [ + new OptimizeCSSAssetsPlugin({}) + ] + }, + plugins: [ + new UglifyJsPlugin({ + uglifyOptions: { output: { comments: false } } + }) + ] +});
\ No newline at end of file |