grasp/extension/webpack.config.js

242 lines
6.3 KiB
JavaScript
Raw Normal View History

const webpack = require('webpack'),
path = require('path'),
{CleanWebpackPlugin} = require('clean-webpack-plugin'),
CopyWebpackPlugin = require('copy-webpack-plugin'),
2020-02-14 15:07:50 -08:00
WebpackExtensionManifestPlugin = require('webpack-extension-manifest-plugin');
const T = {
CHROME : 'chrome',
FIREFOX: 'firefox',
};
// TODO will be conditional on T.CHROME at some point
const v3 = false
const env = {
TARGET : process.env.TARGET,
RELEASE: process.env.RELEASE,
PUBLISH: process.env.PUBLISH,
}
const ext_id = process.env.EXT_ID
2019-01-06 05:42:54 -08:00
const pkg = require('./package.json');
const baseManifest = require('./src/manifest.json');
Collapse boilerplate in a single commit First prototype Added the README Fixed the hot module replacement Minor adjustments on readme Normalizing the env vars and using it capitalized Added info about the react.js branch Fix babel transpiling Using yarn Removing the babel package, just the babel-core does the job Using just the dependencies key on package.json Since it isn't a lib package doesn't matter the separation between devDependencies and dependencies. Updating the css-loader Updating the fs-extra Moving the utility packages to utils folder Better description Adds the license closes #3 Write the env vars on the bundle file http://dev.topheman.com/make-your-react-production-minified-version-with-webpack/ Fixs the hot reload setup Sringifies the env object to define plugin Uses the webpack html plugin to generate the pages in a less hacky way Uses the write-file-webpack-plugin this plugin allows the webpack write on disk all files, even running with the webserver, which is necessary to the hot reload. this plugin also help us to remove nasty hacks and expose bundles to other extension features. Allows exclude some entry points to be hot reloaded It's useful for content scripts that can't keep the connection with the webpack endpoint. Updates the webpack Updates the README with instructions about the content scripts resolves #4 Updates to Webpack 2 closes #8 Expand the DefinePlugin usage In Webpack 1, the replaced value at compile time by define plugin was placed with parenthesis, like ({"NODE_ENV":"development","PORT":3000}), now, it not works in this way, breaking the app. So, to simplify the things, this commit just passes the NODE_ENV var. Fix README Exclude /node_modules/ from babel and css transpiling #9 Source maps to help debugging closes #10 Removes the forbidden webpack config 'chromeExtensionBoilerplate' before build and webserver's start Although I know that it's not a good practice, right now I don't know a good way to keep the boilerplate configs simple as it is today without this hacky solution, so, until we came with a better solution, we'll remove the key before build and webserver's start. #9 Update README.md Removing babel.js Basically, we don't need transpiling with babel since Webpack 2 take care of ES6 modules transpiling and the ES2015 is supported by Chrome. kudos @gagarine resolve #16 Setup boilerplate to load images and other assets in html and css resolves #18 resolves #23 resolves #14 resolves #12 Added icons and images boilerplate Split dependencies on package.json resolves #15 Webpack config improvements (#26) - Use CopyWebpackPlugin to generate `manifest.json` file - Use CleanWebpackPlugin to clear build folder Minor README adjustments * explicitly the required node version * pointing to yarn install instructions page instead suggest install with npm. the yarn page will be always updated to the best way to install the yarn. closes #28 Adding the contribution guidelines
2016-04-14 06:16:50 -07:00
const release = env.RELEASE == 'YES' ? true : false;
const publish = env.PUBLISH == 'YES' ? true : false;
const dev = !release; // meh. maybe make up my mind?
const target = env.TARGET;
2019-01-18 16:41:27 -08:00
const name = "grasp" + (dev ? ' [dev]' : '');
// ugh. declarative formats are shit.
2019-06-29 09:37:31 -07:00
// Firefox wouldn't let you rebind its default shortcuts most of which use Shift
// On the other hand, Chrome wouldn't let you use Alt
const modifier = target === T.CHROME ? 'Shift' : 'Alt'
2019-06-29 09:37:31 -07:00
const action_name = v3 ? 'action' : 'browser_action'
const commands = {
2019-06-29 09:37:31 -07:00
"capture-simple": {
"description": "Quick capture: url, title and selection",
2019-06-29 09:37:31 -07:00
"suggested_key": {
"default": `Ctrl+${modifier}+C`,
"mac": `Command+${modifier}+C`,
},
}
}
commands[`_execute_${action_name}`] = {
"description": "Capture page, with extra information",
2019-06-29 09:37:31 -07:00
"suggested_key": {
"default": `Ctrl+${modifier}+Y`,
"mac": `Command+${modifier}+Y`,
},
}
const action = {
"default_icon": "img/unicorn.png",
"default_popup": "popup.html",
"default_title": "Capture page, with extra information",
}
if (target == T.FIREFOX) {
action['browser_style'] = true
}
const endpoints = (domain) => [
"http://" + domain + "/capture",
"https://" + domain + "/capture",
]
// prepare for manifest v3
const host_permissions = endpoints('localhost')
const optional_host_permissions = endpoints('*')
// TODO make permissions literate
const permissions = [
"storage",
"notifications",
// need to query active tab and get its url/title
"activeTab",
]
const optional_permissions = []
if (target === T.FIREFOX || v3) {
// chrome v2 doesn't support scripting api
// code has a fallback just for that
// (needed to get selected text)
permissions.push("scripting")
}
const content_security_policy = [
"default-src 'self'",
"connect-src " + endpoints('*:*').join(' '),
// FFS, otherwise <style> directives on extension's pages not working??
"style-src 'unsafe-inline'",
].join('; ')
const manifestExtra = {
name: name,
version: pkg.version,
description: pkg.description,
permissions: permissions,
commands: commands,
optional_permissions: optional_permissions,
manifest_version: v3 ? 3 : 2,
background: (v3 ? {
service_worker: 'background.js',
// wtf -- firefox doesn't support module??
// it just fails to load manifest in this case atm
...(target === T.FIREFOX? {} : {type: 'module'}),
} : {
scripts: [
'webextension-polyfill.js',
'background.js',
],
persistent: false,
}),
content_security_policy: v3 ? {
extension_pages: content_security_policy,
} : content_security_policy,
}
manifestExtra[action_name] = action
if (v3) {
manifestExtra['host_permissions'] = host_permissions
manifestExtra['optional_host_permissions'] = optional_host_permissions
if (target === T.FIREFOX) {
manifestExtra['browser_specific_settings'] = {
"gecko": {
"id": ext_id,
},
}
}
} else {
manifestExtra.permissions.push(...host_permissions)
manifestExtra.optional_permissions.push(...optional_host_permissions)
}
if (target === T.FIREFOX) {
manifestExtra.options_ui = {browser_style: true};
}
const buildPath = path.join(__dirname, 'dist', target);
2019-12-09 12:43:38 -08:00
2020-02-14 15:07:50 -08:00
const options = {
mode: dev ? 'development' : 'production', // TODO map directly from MODE env var?
node: {
// no idea what does it mean... https://github.com/webpack/webpack/issues/5627#issuecomment-394290231
// but it does get rid of some Function() which webpacka apparently generates
global: false,
2019-12-09 13:11:07 -08:00
},
Collapse boilerplate in a single commit First prototype Added the README Fixed the hot module replacement Minor adjustments on readme Normalizing the env vars and using it capitalized Added info about the react.js branch Fix babel transpiling Using yarn Removing the babel package, just the babel-core does the job Using just the dependencies key on package.json Since it isn't a lib package doesn't matter the separation between devDependencies and dependencies. Updating the css-loader Updating the fs-extra Moving the utility packages to utils folder Better description Adds the license closes #3 Write the env vars on the bundle file http://dev.topheman.com/make-your-react-production-minified-version-with-webpack/ Fixs the hot reload setup Sringifies the env object to define plugin Uses the webpack html plugin to generate the pages in a less hacky way Uses the write-file-webpack-plugin this plugin allows the webpack write on disk all files, even running with the webserver, which is necessary to the hot reload. this plugin also help us to remove nasty hacks and expose bundles to other extension features. Allows exclude some entry points to be hot reloaded It's useful for content scripts that can't keep the connection with the webpack endpoint. Updates the webpack Updates the README with instructions about the content scripts resolves #4 Updates to Webpack 2 closes #8 Expand the DefinePlugin usage In Webpack 1, the replaced value at compile time by define plugin was placed with parenthesis, like ({"NODE_ENV":"development","PORT":3000}), now, it not works in this way, breaking the app. So, to simplify the things, this commit just passes the NODE_ENV var. Fix README Exclude /node_modules/ from babel and css transpiling #9 Source maps to help debugging closes #10 Removes the forbidden webpack config 'chromeExtensionBoilerplate' before build and webserver's start Although I know that it's not a good practice, right now I don't know a good way to keep the boilerplate configs simple as it is today without this hacky solution, so, until we came with a better solution, we'll remove the key before build and webserver's start. #9 Update README.md Removing babel.js Basically, we don't need transpiling with babel since Webpack 2 take care of ES6 modules transpiling and the ES2015 is supported by Chrome. kudos @gagarine resolve #16 Setup boilerplate to load images and other assets in html and css resolves #18 resolves #23 resolves #14 resolves #12 Added icons and images boilerplate Split dependencies on package.json resolves #15 Webpack config improvements (#26) - Use CopyWebpackPlugin to generate `manifest.json` file - Use CleanWebpackPlugin to clear build folder Minor README adjustments * explicitly the required node version * pointing to yarn install instructions page instead suggest install with npm. the yarn page will be always updated to the best way to install the yarn. closes #28 Adding the contribution guidelines
2016-04-14 06:16:50 -07:00
entry: {
2020-02-14 15:07:50 -08:00
background : path.join(__dirname, "src", "js", "background"),
popup : path.join(__dirname, "src", "js", "popup"),
options_page: path.join(__dirname, "src", "js", "options_page"),
Collapse boilerplate in a single commit First prototype Added the README Fixed the hot module replacement Minor adjustments on readme Normalizing the env vars and using it capitalized Added info about the react.js branch Fix babel transpiling Using yarn Removing the babel package, just the babel-core does the job Using just the dependencies key on package.json Since it isn't a lib package doesn't matter the separation between devDependencies and dependencies. Updating the css-loader Updating the fs-extra Moving the utility packages to utils folder Better description Adds the license closes #3 Write the env vars on the bundle file http://dev.topheman.com/make-your-react-production-minified-version-with-webpack/ Fixs the hot reload setup Sringifies the env object to define plugin Uses the webpack html plugin to generate the pages in a less hacky way Uses the write-file-webpack-plugin this plugin allows the webpack write on disk all files, even running with the webserver, which is necessary to the hot reload. this plugin also help us to remove nasty hacks and expose bundles to other extension features. Allows exclude some entry points to be hot reloaded It's useful for content scripts that can't keep the connection with the webpack endpoint. Updates the webpack Updates the README with instructions about the content scripts resolves #4 Updates to Webpack 2 closes #8 Expand the DefinePlugin usage In Webpack 1, the replaced value at compile time by define plugin was placed with parenthesis, like ({"NODE_ENV":"development","PORT":3000}), now, it not works in this way, breaking the app. So, to simplify the things, this commit just passes the NODE_ENV var. Fix README Exclude /node_modules/ from babel and css transpiling #9 Source maps to help debugging closes #10 Removes the forbidden webpack config 'chromeExtensionBoilerplate' before build and webserver's start Although I know that it's not a good practice, right now I don't know a good way to keep the boilerplate configs simple as it is today without this hacky solution, so, until we came with a better solution, we'll remove the key before build and webserver's start. #9 Update README.md Removing babel.js Basically, we don't need transpiling with babel since Webpack 2 take care of ES6 modules transpiling and the ES2015 is supported by Chrome. kudos @gagarine resolve #16 Setup boilerplate to load images and other assets in html and css resolves #18 resolves #23 resolves #14 resolves #12 Added icons and images boilerplate Split dependencies on package.json resolves #15 Webpack config improvements (#26) - Use CopyWebpackPlugin to generate `manifest.json` file - Use CleanWebpackPlugin to clear build folder Minor README adjustments * explicitly the required node version * pointing to yarn install instructions page instead suggest install with npm. the yarn page will be always updated to the best way to install the yarn. closes #28 Adding the contribution guidelines
2016-04-14 06:16:50 -07:00
},
output: {
path: buildPath,
Collapse boilerplate in a single commit First prototype Added the README Fixed the hot module replacement Minor adjustments on readme Normalizing the env vars and using it capitalized Added info about the react.js branch Fix babel transpiling Using yarn Removing the babel package, just the babel-core does the job Using just the dependencies key on package.json Since it isn't a lib package doesn't matter the separation between devDependencies and dependencies. Updating the css-loader Updating the fs-extra Moving the utility packages to utils folder Better description Adds the license closes #3 Write the env vars on the bundle file http://dev.topheman.com/make-your-react-production-minified-version-with-webpack/ Fixs the hot reload setup Sringifies the env object to define plugin Uses the webpack html plugin to generate the pages in a less hacky way Uses the write-file-webpack-plugin this plugin allows the webpack write on disk all files, even running with the webserver, which is necessary to the hot reload. this plugin also help us to remove nasty hacks and expose bundles to other extension features. Allows exclude some entry points to be hot reloaded It's useful for content scripts that can't keep the connection with the webpack endpoint. Updates the webpack Updates the README with instructions about the content scripts resolves #4 Updates to Webpack 2 closes #8 Expand the DefinePlugin usage In Webpack 1, the replaced value at compile time by define plugin was placed with parenthesis, like ({"NODE_ENV":"development","PORT":3000}), now, it not works in this way, breaking the app. So, to simplify the things, this commit just passes the NODE_ENV var. Fix README Exclude /node_modules/ from babel and css transpiling #9 Source maps to help debugging closes #10 Removes the forbidden webpack config 'chromeExtensionBoilerplate' before build and webserver's start Although I know that it's not a good practice, right now I don't know a good way to keep the boilerplate configs simple as it is today without this hacky solution, so, until we came with a better solution, we'll remove the key before build and webserver's start. #9 Update README.md Removing babel.js Basically, we don't need transpiling with babel since Webpack 2 take care of ES6 modules transpiling and the ES2015 is supported by Chrome. kudos @gagarine resolve #16 Setup boilerplate to load images and other assets in html and css resolves #18 resolves #23 resolves #14 resolves #12 Added icons and images boilerplate Split dependencies on package.json resolves #15 Webpack config improvements (#26) - Use CopyWebpackPlugin to generate `manifest.json` file - Use CleanWebpackPlugin to clear build folder Minor README adjustments * explicitly the required node version * pointing to yarn install instructions page instead suggest install with npm. the yarn page will be always updated to the best way to install the yarn. closes #28 Adding the contribution guidelines
2016-04-14 06:16:50 -07:00
},
optimization: {
// https://webpack.js.org/configuration/optimization
// don't think minimize worth it for such a tiny extension
minimize: false,
// split chunks is so vendors split out into separate js files
// to prevent bloating individual source files
// seems that at the moment we need to manually load the chunks in the corresponding
// html files or manifest
// split chunks doc recommend using webpack html plugin??
splitChunks: {
// seems necessary, otherwise doesn't split out polyfill??
chunks: 'all',
cacheGroups: {
vendor: {
test: /[\\/]node_modules[\\/]/,
name(module) {
const packageName = module.context.match(/[\\/]node_modules[\\/](.*?)([\\/]|$)/)[1];
return packageName
},
// create chunk regardless size etc
enforce: true,
},
},
},
},
Collapse boilerplate in a single commit First prototype Added the README Fixed the hot module replacement Minor adjustments on readme Normalizing the env vars and using it capitalized Added info about the react.js branch Fix babel transpiling Using yarn Removing the babel package, just the babel-core does the job Using just the dependencies key on package.json Since it isn't a lib package doesn't matter the separation between devDependencies and dependencies. Updating the css-loader Updating the fs-extra Moving the utility packages to utils folder Better description Adds the license closes #3 Write the env vars on the bundle file http://dev.topheman.com/make-your-react-production-minified-version-with-webpack/ Fixs the hot reload setup Sringifies the env object to define plugin Uses the webpack html plugin to generate the pages in a less hacky way Uses the write-file-webpack-plugin this plugin allows the webpack write on disk all files, even running with the webserver, which is necessary to the hot reload. this plugin also help us to remove nasty hacks and expose bundles to other extension features. Allows exclude some entry points to be hot reloaded It's useful for content scripts that can't keep the connection with the webpack endpoint. Updates the webpack Updates the README with instructions about the content scripts resolves #4 Updates to Webpack 2 closes #8 Expand the DefinePlugin usage In Webpack 1, the replaced value at compile time by define plugin was placed with parenthesis, like ({"NODE_ENV":"development","PORT":3000}), now, it not works in this way, breaking the app. So, to simplify the things, this commit just passes the NODE_ENV var. Fix README Exclude /node_modules/ from babel and css transpiling #9 Source maps to help debugging closes #10 Removes the forbidden webpack config 'chromeExtensionBoilerplate' before build and webserver's start Although I know that it's not a good practice, right now I don't know a good way to keep the boilerplate configs simple as it is today without this hacky solution, so, until we came with a better solution, we'll remove the key before build and webserver's start. #9 Update README.md Removing babel.js Basically, we don't need transpiling with babel since Webpack 2 take care of ES6 modules transpiling and the ES2015 is supported by Chrome. kudos @gagarine resolve #16 Setup boilerplate to load images and other assets in html and css resolves #18 resolves #23 resolves #14 resolves #12 Added icons and images boilerplate Split dependencies on package.json resolves #15 Webpack config improvements (#26) - Use CopyWebpackPlugin to generate `manifest.json` file - Use CleanWebpackPlugin to clear build folder Minor README adjustments * explicitly the required node version * pointing to yarn install instructions page instead suggest install with npm. the yarn page will be always updated to the best way to install the yarn. closes #28 Adding the contribution guidelines
2016-04-14 06:16:50 -07:00
module: {
rules: [
2019-01-04 13:27:24 -08:00
{
test: /\.js$/,
loader: 'babel-loader',
2019-01-04 13:27:24 -08:00
exclude: /node_modules/,
},
Collapse boilerplate in a single commit First prototype Added the README Fixed the hot module replacement Minor adjustments on readme Normalizing the env vars and using it capitalized Added info about the react.js branch Fix babel transpiling Using yarn Removing the babel package, just the babel-core does the job Using just the dependencies key on package.json Since it isn't a lib package doesn't matter the separation between devDependencies and dependencies. Updating the css-loader Updating the fs-extra Moving the utility packages to utils folder Better description Adds the license closes #3 Write the env vars on the bundle file http://dev.topheman.com/make-your-react-production-minified-version-with-webpack/ Fixs the hot reload setup Sringifies the env object to define plugin Uses the webpack html plugin to generate the pages in a less hacky way Uses the write-file-webpack-plugin this plugin allows the webpack write on disk all files, even running with the webserver, which is necessary to the hot reload. this plugin also help us to remove nasty hacks and expose bundles to other extension features. Allows exclude some entry points to be hot reloaded It's useful for content scripts that can't keep the connection with the webpack endpoint. Updates the webpack Updates the README with instructions about the content scripts resolves #4 Updates to Webpack 2 closes #8 Expand the DefinePlugin usage In Webpack 1, the replaced value at compile time by define plugin was placed with parenthesis, like ({"NODE_ENV":"development","PORT":3000}), now, it not works in this way, breaking the app. So, to simplify the things, this commit just passes the NODE_ENV var. Fix README Exclude /node_modules/ from babel and css transpiling #9 Source maps to help debugging closes #10 Removes the forbidden webpack config 'chromeExtensionBoilerplate' before build and webserver's start Although I know that it's not a good practice, right now I don't know a good way to keep the boilerplate configs simple as it is today without this hacky solution, so, until we came with a better solution, we'll remove the key before build and webserver's start. #9 Update README.md Removing babel.js Basically, we don't need transpiling with babel since Webpack 2 take care of ES6 modules transpiling and the ES2015 is supported by Chrome. kudos @gagarine resolve #16 Setup boilerplate to load images and other assets in html and css resolves #18 resolves #23 resolves #14 resolves #12 Added icons and images boilerplate Split dependencies on package.json resolves #15 Webpack config improvements (#26) - Use CopyWebpackPlugin to generate `manifest.json` file - Use CleanWebpackPlugin to clear build folder Minor README adjustments * explicitly the required node version * pointing to yarn install instructions page instead suggest install with npm. the yarn page will be always updated to the best way to install the yarn. closes #28 Adding the contribution guidelines
2016-04-14 06:16:50 -07:00
{
test: /\.css$/,
use: 'style-loader!css-loader',
exclude: /node_modules/,
Collapse boilerplate in a single commit First prototype Added the README Fixed the hot module replacement Minor adjustments on readme Normalizing the env vars and using it capitalized Added info about the react.js branch Fix babel transpiling Using yarn Removing the babel package, just the babel-core does the job Using just the dependencies key on package.json Since it isn't a lib package doesn't matter the separation between devDependencies and dependencies. Updating the css-loader Updating the fs-extra Moving the utility packages to utils folder Better description Adds the license closes #3 Write the env vars on the bundle file http://dev.topheman.com/make-your-react-production-minified-version-with-webpack/ Fixs the hot reload setup Sringifies the env object to define plugin Uses the webpack html plugin to generate the pages in a less hacky way Uses the write-file-webpack-plugin this plugin allows the webpack write on disk all files, even running with the webserver, which is necessary to the hot reload. this plugin also help us to remove nasty hacks and expose bundles to other extension features. Allows exclude some entry points to be hot reloaded It's useful for content scripts that can't keep the connection with the webpack endpoint. Updates the webpack Updates the README with instructions about the content scripts resolves #4 Updates to Webpack 2 closes #8 Expand the DefinePlugin usage In Webpack 1, the replaced value at compile time by define plugin was placed with parenthesis, like ({"NODE_ENV":"development","PORT":3000}), now, it not works in this way, breaking the app. So, to simplify the things, this commit just passes the NODE_ENV var. Fix README Exclude /node_modules/ from babel and css transpiling #9 Source maps to help debugging closes #10 Removes the forbidden webpack config 'chromeExtensionBoilerplate' before build and webserver's start Although I know that it's not a good practice, right now I don't know a good way to keep the boilerplate configs simple as it is today without this hacky solution, so, until we came with a better solution, we'll remove the key before build and webserver's start. #9 Update README.md Removing babel.js Basically, we don't need transpiling with babel since Webpack 2 take care of ES6 modules transpiling and the ES2015 is supported by Chrome. kudos @gagarine resolve #16 Setup boilerplate to load images and other assets in html and css resolves #18 resolves #23 resolves #14 resolves #12 Added icons and images boilerplate Split dependencies on package.json resolves #15 Webpack config improvements (#26) - Use CopyWebpackPlugin to generate `manifest.json` file - Use CleanWebpackPlugin to clear build folder Minor README adjustments * explicitly the required node version * pointing to yarn install instructions page instead suggest install with npm. the yarn page will be always updated to the best way to install the yarn. closes #28 Adding the contribution guidelines
2016-04-14 06:16:50 -07:00
},
{
test: /\.html$/,
loader: 'html-loader',
Collapse boilerplate in a single commit First prototype Added the README Fixed the hot module replacement Minor adjustments on readme Normalizing the env vars and using it capitalized Added info about the react.js branch Fix babel transpiling Using yarn Removing the babel package, just the babel-core does the job Using just the dependencies key on package.json Since it isn't a lib package doesn't matter the separation between devDependencies and dependencies. Updating the css-loader Updating the fs-extra Moving the utility packages to utils folder Better description Adds the license closes #3 Write the env vars on the bundle file http://dev.topheman.com/make-your-react-production-minified-version-with-webpack/ Fixs the hot reload setup Sringifies the env object to define plugin Uses the webpack html plugin to generate the pages in a less hacky way Uses the write-file-webpack-plugin this plugin allows the webpack write on disk all files, even running with the webserver, which is necessary to the hot reload. this plugin also help us to remove nasty hacks and expose bundles to other extension features. Allows exclude some entry points to be hot reloaded It's useful for content scripts that can't keep the connection with the webpack endpoint. Updates the webpack Updates the README with instructions about the content scripts resolves #4 Updates to Webpack 2 closes #8 Expand the DefinePlugin usage In Webpack 1, the replaced value at compile time by define plugin was placed with parenthesis, like ({"NODE_ENV":"development","PORT":3000}), now, it not works in this way, breaking the app. So, to simplify the things, this commit just passes the NODE_ENV var. Fix README Exclude /node_modules/ from babel and css transpiling #9 Source maps to help debugging closes #10 Removes the forbidden webpack config 'chromeExtensionBoilerplate' before build and webserver's start Although I know that it's not a good practice, right now I don't know a good way to keep the boilerplate configs simple as it is today without this hacky solution, so, until we came with a better solution, we'll remove the key before build and webserver's start. #9 Update README.md Removing babel.js Basically, we don't need transpiling with babel since Webpack 2 take care of ES6 modules transpiling and the ES2015 is supported by Chrome. kudos @gagarine resolve #16 Setup boilerplate to load images and other assets in html and css resolves #18 resolves #23 resolves #14 resolves #12 Added icons and images boilerplate Split dependencies on package.json resolves #15 Webpack config improvements (#26) - Use CopyWebpackPlugin to generate `manifest.json` file - Use CleanWebpackPlugin to clear build folder Minor README adjustments * explicitly the required node version * pointing to yarn install instructions page instead suggest install with npm. the yarn page will be always updated to the best way to install the yarn. closes #28 Adding the contribution guidelines
2016-04-14 06:16:50 -07:00
exclude: /node_modules/
}
]
},
plugins: [
new CleanWebpackPlugin(), // ok, respects symlinks
// without copy pluging, webpack only bundles js/json files
new CopyWebpackPlugin({
patterns: [
{ context: 'src', from: '**/*.html' },
{ context: 'src', from: '**/*.png' },
]
}),
2019-01-06 05:42:54 -08:00
new WebpackExtensionManifestPlugin({
config: {
base: baseManifest,
extend: manifestExtra,
2019-01-06 05:42:54 -08:00
}
}),
],
// docs claim it's the slowest but pretty fast anyway
devtool: 'source-map',
Collapse boilerplate in a single commit First prototype Added the README Fixed the hot module replacement Minor adjustments on readme Normalizing the env vars and using it capitalized Added info about the react.js branch Fix babel transpiling Using yarn Removing the babel package, just the babel-core does the job Using just the dependencies key on package.json Since it isn't a lib package doesn't matter the separation between devDependencies and dependencies. Updating the css-loader Updating the fs-extra Moving the utility packages to utils folder Better description Adds the license closes #3 Write the env vars on the bundle file http://dev.topheman.com/make-your-react-production-minified-version-with-webpack/ Fixs the hot reload setup Sringifies the env object to define plugin Uses the webpack html plugin to generate the pages in a less hacky way Uses the write-file-webpack-plugin this plugin allows the webpack write on disk all files, even running with the webserver, which is necessary to the hot reload. this plugin also help us to remove nasty hacks and expose bundles to other extension features. Allows exclude some entry points to be hot reloaded It's useful for content scripts that can't keep the connection with the webpack endpoint. Updates the webpack Updates the README with instructions about the content scripts resolves #4 Updates to Webpack 2 closes #8 Expand the DefinePlugin usage In Webpack 1, the replaced value at compile time by define plugin was placed with parenthesis, like ({"NODE_ENV":"development","PORT":3000}), now, it not works in this way, breaking the app. So, to simplify the things, this commit just passes the NODE_ENV var. Fix README Exclude /node_modules/ from babel and css transpiling #9 Source maps to help debugging closes #10 Removes the forbidden webpack config 'chromeExtensionBoilerplate' before build and webserver's start Although I know that it's not a good practice, right now I don't know a good way to keep the boilerplate configs simple as it is today without this hacky solution, so, until we came with a better solution, we'll remove the key before build and webserver's start. #9 Update README.md Removing babel.js Basically, we don't need transpiling with babel since Webpack 2 take care of ES6 modules transpiling and the ES2015 is supported by Chrome. kudos @gagarine resolve #16 Setup boilerplate to load images and other assets in html and css resolves #18 resolves #23 resolves #14 resolves #12 Added icons and images boilerplate Split dependencies on package.json resolves #15 Webpack config improvements (#26) - Use CopyWebpackPlugin to generate `manifest.json` file - Use CleanWebpackPlugin to clear build folder Minor README adjustments * explicitly the required node version * pointing to yarn install instructions page instead suggest install with npm. the yarn page will be always updated to the best way to install the yarn. closes #28 Adding the contribution guidelines
2016-04-14 06:16:50 -07:00
}
Collapse boilerplate in a single commit First prototype Added the README Fixed the hot module replacement Minor adjustments on readme Normalizing the env vars and using it capitalized Added info about the react.js branch Fix babel transpiling Using yarn Removing the babel package, just the babel-core does the job Using just the dependencies key on package.json Since it isn't a lib package doesn't matter the separation between devDependencies and dependencies. Updating the css-loader Updating the fs-extra Moving the utility packages to utils folder Better description Adds the license closes #3 Write the env vars on the bundle file http://dev.topheman.com/make-your-react-production-minified-version-with-webpack/ Fixs the hot reload setup Sringifies the env object to define plugin Uses the webpack html plugin to generate the pages in a less hacky way Uses the write-file-webpack-plugin this plugin allows the webpack write on disk all files, even running with the webserver, which is necessary to the hot reload. this plugin also help us to remove nasty hacks and expose bundles to other extension features. Allows exclude some entry points to be hot reloaded It's useful for content scripts that can't keep the connection with the webpack endpoint. Updates the webpack Updates the README with instructions about the content scripts resolves #4 Updates to Webpack 2 closes #8 Expand the DefinePlugin usage In Webpack 1, the replaced value at compile time by define plugin was placed with parenthesis, like ({"NODE_ENV":"development","PORT":3000}), now, it not works in this way, breaking the app. So, to simplify the things, this commit just passes the NODE_ENV var. Fix README Exclude /node_modules/ from babel and css transpiling #9 Source maps to help debugging closes #10 Removes the forbidden webpack config 'chromeExtensionBoilerplate' before build and webserver's start Although I know that it's not a good practice, right now I don't know a good way to keep the boilerplate configs simple as it is today without this hacky solution, so, until we came with a better solution, we'll remove the key before build and webserver's start. #9 Update README.md Removing babel.js Basically, we don't need transpiling with babel since Webpack 2 take care of ES6 modules transpiling and the ES2015 is supported by Chrome. kudos @gagarine resolve #16 Setup boilerplate to load images and other assets in html and css resolves #18 resolves #23 resolves #14 resolves #12 Added icons and images boilerplate Split dependencies on package.json resolves #15 Webpack config improvements (#26) - Use CopyWebpackPlugin to generate `manifest.json` file - Use CleanWebpackPlugin to clear build folder Minor README adjustments * explicitly the required node version * pointing to yarn install instructions page instead suggest install with npm. the yarn page will be always updated to the best way to install the yarn. closes #28 Adding the contribution guidelines
2016-04-14 06:16:50 -07:00
module.exports = options;