Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX Fix devtool error and remove comments in prod #54

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ module.exports = [
path: PATHS.DIST,
filename: 'js/[name].js',
},
devtool: (ENV !== 'production') ? 'source-map' : '',
devtool: (ENV !== 'production') ? 'source-map' : false,
resolve: resolveJS(ENV, PATHS),
externals: externalJS(ENV, PATHS),
module: moduleJS(ENV, PATHS),
Expand All @@ -228,7 +228,7 @@ module.exports = [
output: {
path: PATHS.DIST,
},
devtool: (ENV !== 'production') ? 'source-map' : '',
devtool: (ENV !== 'production') ? 'source-map' : false,
module: moduleCSS(ENV, PATHS),
// Pass the filename here, which will get passed down to MiniCssExtractPlugin
plugins: pluginCSS(ENV, PATHS, 'css/[name].css'),
Expand Down
22 changes: 12 additions & 10 deletions configMeta/baseWebpackConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,19 +53,21 @@ module.exports = class BaseWebpackConfig {

this.#vendorChunk = vendorChunk;

this.#config.optimization = {
splitChunks: {
cacheGroups: {
vendor: {
name: vendorChunk,
test: test,
reuseExistingChunk: true,
enforce: true,
chunks: 'all',
this.mergeConfig({
optimization: {
splitChunks: {
cacheGroups: {
vendor: {
name: vendorChunk,
test: test,
reuseExistingChunk: true,
enforce: true,
chunks: 'all',
}
}
}
}
};
});

// ensure entries are configured to "depend on" the vendor entry if necessary
this.#splitVendorFromEntries();
Expand Down
2 changes: 1 addition & 1 deletion configMeta/cssWebpackConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ module.exports = class CssWebpackConfig extends BaseWebpackConfig {
output: {
path: PATHS.DIST,
},
devtool: (ENV !== 'production') ? 'source-map' : '',
devtool: (ENV !== 'production') ? 'source-map' : false,
module: moduleCSS(ENV, PATHS),
plugins: pluginCSS(ENV, PATHS, filename),
});
Expand Down
16 changes: 15 additions & 1 deletion configMeta/javascriptWebpackConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const externalJS = require('../js/externals');
const moduleJS = require('../js/modules');
const pluginJS = require('../js/plugins');
const resolveJS = require('../js/resolve');
const TerserPlugin = require('terser-webpack-plugin');

/**
* Dynamically generates webpack config for transpiling javascript using Silverstripe default settings
Expand All @@ -19,11 +20,24 @@ module.exports = class JavascriptWebpackConfig extends BaseWebpackConfig {
path: PATHS.DIST,
filename: 'js/[name].js',
},
devtool: (ENV !== 'production') ? 'source-map' : '',
devtool: (ENV !== 'production') ? 'source-map' : false,
resolve: resolveJS(ENV, PATHS),
module: moduleJS(ENV, PATHS),
externals: externalJS(ENV, PATHS, moduleName),
plugins: pluginJS(ENV),
optimization: {
minimize: true,
minimizer: [
new TerserPlugin({
extractComments: false,
terserOptions: {
format: {
comments: false,
},
},
}),
],
},
});
}
}