diff options
author | Humberto Alfonso Díaz <humberto.alfonso@asvito.es> | 2019-12-09 11:43:22 +0100 |
---|---|---|
committer | Lorenzo Tilve <ltilve@igalia.com> | 2020-02-04 19:03:18 +0100 |
commit | aa8165f9173cf95c18deaaf0ce4e685d2cce3775 (patch) | |
tree | 2cb15dd8be01b9c8b18c7f69d39f2a82de1b6ee0 /webpack.config.js | |
parent | 12caee8305924b9dcaf23dc71f36129d3993c5ca (diff) |
STRUCT First structure for the repo
Diffstat (limited to 'webpack.config.js')
-rw-r--r-- | webpack.config.js | 125 |
1 files changed, 125 insertions, 0 deletions
diff --git a/webpack.config.js b/webpack.config.js new file mode 100644 index 0000000..16a3f83 --- /dev/null +++ b/webpack.config.js @@ -0,0 +1,125 @@ +const path = require('path'); +const UglifyJsPlugin = require('uglifyjs-webpack-plugin'); +const CleanWebpackPlugin = require('clean-webpack-plugin'); +const HtmlWebpackPlugin = require('html-webpack-plugin'); +const MiniCSSExtractPlugin = require('mini-css-extract-plugin'); +const CopyPlugin = require('copy-webpack-plugin'); +const ZipPlugin = require('zip-webpack-plugin'); + + +module.exports = { + mode: 'production', + entry: { + index: './src/index.js' + }, + output: { + path: __dirname + '/dist', + filename: '[name].js', + libraryTarget: 'var', + // `library` determines the name of the global variable + library: '[name]' + }, + optimization: { + minimizer: [new UglifyJsPlugin()], + }, + plugins: [ + new CleanWebpackPlugin(['dist']), + new CopyPlugin([ + { + from: 'src/icon.*', + flatten: true + }, + { + from: 'src/config.xml', + flatten: true + }, + { + from: 'src/mockups/*', + to: 'mockups/', + flatten: true + }, + { + from: 'src/images/*', + to: 'images/', + flatten: true + }, + { + from: 'src/templates/*', + to: 'templates/', + flatten: true + } + ]), + new HtmlWebpackPlugin({ + template: 'src/index.html', + filename: 'index.html', + inject: 'body' + }), + new MiniCSSExtractPlugin({ + filename: 'app.css', + path: __dirname + '/dist' + }), + new ZipPlugin({ + path: __dirname + '/package', + filename: 'dashboard', + extension: 'wgt', + exclude: [] + }) + ], + module: { + rules: [ + { + test: /\.css$/, + use: [ + 'style-loader', + 'css-loader' + ] + }, + { + test: /\.scss$/, + use: [ + MiniCSSExtractPlugin.loader, + "css-loader", + { + loader: 'sass-loader', + options: { + sassOptions: { + indentWidth: 4, + includePaths: ['./src', './node_modules'], + }, + }, + }, + ] + }, + { + test: /\.(woff(2)?|ttf|eot|svg)(\?v=\d+\.\d+\.\d+)?$/, + use: [ + { + loader: 'file-loader', + options: { + name: '[name].[ext]', + outputPath: 'fonts/' + } + } + ] + }, + { + test: /\.(gif|png|jpe?g|svg)$/i, + use: [ + 'file-loader', + { + loader: "image-webpack-loader", + options: { + bypassOnDebug: true, // webpack@1.x + disable: true, // webpack@2.x and newer + }, + } + ] + } + ] + }, + devServer: { + contentBase: path.join(__dirname, 'dist'), + compress: true, + port: 9000 + } +};
\ No newline at end of file |