Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * -----------------------------------------------------------------------
- Run `webpack` and it will produce unminified output with sourcemaps.
- Run `NODE_ENV=production webpack` and it will minify the output and
- de-dupe all the unnecessary code.
- * -----------------------------------------------------------------------
- */
- var debug = process.env.NODE_ENV !== "production";
- var webpack = require('webpack');
- var path = require('path');
- const CopyPlugin = require('copy-webpack-plugin');
- const static_js_folder_dist = __dirname + '/js/dist/';
- const theme_js_folder = '../../../themes/custom/vanmoof/assets/js/';
- const theme_js_folder_dist = theme_js_folder + 'dist/';
- const theme_js_folder_lib = theme_js_folder + 'lib/';
- console.log("Webpack running in debug: " + debug);
- console.log("Theme JS folder: " + theme_js_folder);
- console.log("Webpack version: " + webpack.Version);
- console.log("Dirname: " + __dirname + ' (target JS: ' + static_js_folder_dist + ')');
- module.exports = {
- context: path.join(__dirname, "js/"),
- // comment source map so drupal doesn't break when doing aggregation
- // devtool: debug ? "eval-source-map" : true,
- entry: "./bundle.js",
- module: {
- rules: [{
- test: /\.jsx?$/,
- exclude: /(node_modules|bower_components)/,
- loader: 'babel-loader',
- query: {
- presets: ['es2015', 'stage-0'],
- plugins: [],
- }
- }]
- },
- output: {
- path: static_js_folder_dist,
- filename: "bundle.min.js"
- },
- plugins: debug ? [
- new CopyPlugin([
- { from: 'dist', to: theme_js_folder_dist },
- ], { logLevel: 'debug' }, { copyUnmodified: true }),
- new CopyPlugin([
- { from: 'lib', to: theme_js_folder_lib },
- ], { logLevel: 'warn' }, { copyUnmodified: true })
- ] :
- [
- new CopyPlugin([
- { from: 'dist', to: theme_js_folder_dist },
- ], { logLevel: 'warn' }, { copyUnmodified: true }),
- new CopyPlugin([
- { from: 'lib', to: theme_js_folder_lib },
- ], { logLevel: 'warn' }, { copyUnmodified: true }),
- new webpack.ContextReplacementPlugin(
- /moment[/\\]locale$/,
- /de|fr|nl|ja/
- ),
- new webpack.optimize.DedupePlugin(),
- new webpack.optimize.OccurrenceOrderPlugin(),
- new webpack.optimize.UglifyJsPlugin({ mangle: false, sourceMap: false }),
- new webpack.ProvidePlugin({
- $: 'jquery',
- jQuery: 'jquery'
- }),
- ],
- mode: 'development' //will cause errors with webpack <4
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement