Skip to content

Commit

Permalink
fix: Switch from rollup to webpack for bundling JS
Browse files Browse the repository at this point in the history
- Remove Rollup, related dependencies, and config

- Add Webpack, related dependencies, and config

- Add webpack.config.js and tweak npm scripts for build process

- Upgrade from babel-preset-es2015 to babel-preset-env

- Upgrade expected Node version to 8.9.4

- Add addon.xpi build artifact to .gitignore

Fixes bwinton#385.
  • Loading branch information
lmorchard committed Jan 11, 2018
1 parent d708cbf commit 9ca4fdc
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 71 deletions.
2 changes: 1 addition & 1 deletion .babelrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"presets": ["es2015", "stage-0", "react"]
"presets": ["env", "stage-0", "react"]
}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
.DS_Store
profile.testing/
web-ext-artifacts/
addon.xpi
dist/
node_modules
*.zip
Expand Down
2 changes: 1 addition & 1 deletion circle.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
machine:
node:
version: 6.9.1
version: 8.9.4

compile:
override:
Expand Down
54 changes: 23 additions & 31 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,15 @@
"bugs": {
"url": "https://github.com/bwinton/SnoozeTabs/issues"
},
"engines": {
"node": ">=8.9.4"
},
"devDependencies": {
"@kadira/storybook": "2.35.3",
"@kadira/storybook-addon-knobs": "1.7.1",
"babel-cli": "6.23.0",
"babel-plugin-external-helpers": "6.18.0",
"babel-preset-es2015": "6.18.0",
"babel-loader": "7.1.1",
"babel-preset-env": "1.6.1",
"babel-preset-react": "6.16.0",
"babel-preset-stage-0": "6.16.0",
"babel-register": "6.18.0",
Expand All @@ -26,26 +29,32 @@
"eslint": "3.10.2",
"eslint-plugin-promise": "3.4.0",
"eslint-plugin-react": "6.8.0",
"json-loader": "0.5.7",
"mocha": "3.2.0",
"node-sass": "3.13.0",
"npm-run-all": "3.1.2",
"onchange": "3.2.0",
"pontoon-to-webext": "1.0.1",
"rollup": "0.36.4",
"rollup-analyzer": "1.0.1",
"rollup-plugin-babel": "2.6.1",
"rollup-plugin-commonjs": "5.0.5",
"rollup-plugin-conditional": "1.1.1",
"rollup-plugin-json": "2.1.0",
"rollup-plugin-node-resolve": "2.0.0",
"rollup-plugin-replace": "1.1.1",
"rollup-plugin-uglify": "1.0.1",
"sass-lint": "1.10.2",
"shx": "0.2.1",
"sinon": "1.17.6",
"storybook-host": "1.0.8",
"svgo": "0.7.1",
"web-ext": "1.8.1"
"web-ext": "1.8.1",
"webpack": "3.10.0"
},
"dependencies": {
"classnames": "2.2.5",
"moment": "2.17.1",
"rc-animate": "2.3.1",
"rc-calendar": "8.1.0",
"rc-time-picker": "2.2.1",
"rc-trigger": "1.8.1",
"react": "15.4.1",
"react-addons-css-transition-group": "15.4.2",
"react-dom": "15.4.1",
"testpilot-metrics": "2.1.2",
"uuid": "3.0.1"
},
"keywords": [
"snooze",
Expand Down Expand Up @@ -109,19 +118,15 @@
"copy:assets": "shx cp -r src/icons dist/ && svgo dist/icons --quiet && shx cp -r src/popup/*.html src/popup/FiraSans-Regular.* dist/popup/",
"copy:js": "shx cp node_modules/testpilot-metrics/testpilot-metrics.js dist/",
"bundle:manifest": "node ./bin/generate-manifest",
"bundle:js": "npm run lint:js && npm-run-all --parallel rollup:*",
"rollup:background": "rollup -c --environment entry:background",
"rollup:snooze-content": "rollup -c --environment entry:popup/snooze-content",
"rollup:snooze-bootstrap": "rollup -c --environment entry:popup/snooze-bootstrap",
"rollup:confirm-bar": "rollup -c --environment entry:lib/confirm-bar",
"bundle:js": "npm run lint:js && webpack",
"bundle:css": "npm run lint:sass && shx mkdir -p dist/popup && node-sass src/popup/snooze.scss > dist/popup/snooze.css",
"package": "cross-env NODE_ENV=production npm run build && web-ext build -s dist && mv web-ext-artifacts/*.zip addon.xpi",
"package:dev": "cross-env NODE_ENV=development npm run build && web-ext build -s dist && mv web-ext-artifacts/*.zip addon-dev.xpi",
"lint": "npm-run-all --parallel lint:*",
"lint:js": "eslint --max-warnings=0 .",
"lint:sass": "sass-lint --max-warnings 0 --verbose --no-exit",
"watch:manifest": "onchange -p -v 'bin/generate-manifest.js' 'package.json' -- npm run bundle:manifest",
"watch:js": "onchange -p -v 'src/**/*.js' -- npm-run-all --parallel bundle:js test:js",
"watch:js": "webpack --watch --progress",
"watch:test:js": "onchange -p -v 'test/**/*.js' -- npm-run-all --parallel test:js",
"watch:css": "onchange -p -v 'src/**/*.scss' -- npm run bundle:css",
"watch:assets": "onchange -p -v 'src/icons/*' 'src/popup/*.html' -- npm run copy:assets",
Expand All @@ -130,18 +135,5 @@
"build-storybook": "build-storybook",
"test": "npm run lint && npm run test:js",
"test:js": "mocha --compilers js:babel-register --require test/.setup.js --recursive"
},
"dependencies": {
"classnames": "2.2.5",
"moment": "2.17.1",
"rc-animate": "2.3.1",
"rc-calendar": "8.1.0",
"rc-time-picker": "2.2.1",
"rc-trigger": "1.8.1",
"react": "15.4.1",
"react-addons-css-transition-group": "15.4.2",
"react-dom": "15.4.1",
"testpilot-metrics": "2.1.2",
"uuid": "3.0.1"
}
}
38 changes: 0 additions & 38 deletions rollup.config.js

This file was deleted.

39 changes: 39 additions & 0 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
const path = require('path');
const webpack = require('webpack');

const NODE_ENV = process.env.NODE_ENV || 'development';

module.exports = {
output: {
path: path.resolve(__dirname, 'dist'),
filename: '[name].js'
},
entry: {
background: './src/background.js',
'popup/snooze-content': './src/popup/snooze-content.js',
'popup/snooze-bootstrap': './src/popup/snooze-bootstrap.js',
'lib/confirm-bar': './src/lib/confirm-bar.js'
},
plugins: [
new webpack.DefinePlugin({
'process.env.NODE_ENV': `"${NODE_ENV}"`
})
],
module: {
loaders: [
{
test: /\.(js|jsx)/,
exclude: /node_modules/,
loader: 'babel-loader',
options: {
babelrc: false,
presets: [ [ 'env', { modules: false } ], 'stage-0', 'react' ],
}
},
{
test: /\.json$/,
loader: 'json-loader'
}
]
}
};

0 comments on commit 9ca4fdc

Please sign in to comment.