Merge pull request #222 from seanyesmunt/webpack-2

webpack@2
This commit is contained in:
Jeremy Kauffman 2017-06-12 12:07:12 -04:00 committed by GitHub
commit c47fb7cb2b
3 changed files with 64 additions and 60 deletions

View file

@ -42,7 +42,7 @@
"devDependencies": { "devDependencies": {
"babel": "^6.5.2", "babel": "^6.5.2",
"babel-core": "^6.18.2", "babel-core": "^6.18.2",
"babel-loader": "^6.2.8", "babel-loader": "^6.4.1",
"babel-plugin-react-require": "^3.0.0", "babel-plugin-react-require": "^3.0.0",
"babel-polyfill": "^6.20.0", "babel-polyfill": "^6.20.0",
"babel-preset-es2015": "^6.18.0", "babel-preset-es2015": "^6.18.0",
@ -59,7 +59,7 @@
"lint-staged": "^3.6.0", "lint-staged": "^3.6.0",
"node-sass": "^3.13.0", "node-sass": "^3.13.0",
"prettier": "^1.4.2", "prettier": "^1.4.2",
"webpack": "^1.13.3", "webpack": "^2.6.1",
"webpack-dev-server": "^2.4.4", "webpack-dev-server": "^2.4.4",
"webpack-notifier": "^1.5.0", "webpack-notifier": "^1.5.0",
"webpack-target-electron-renderer": "^0.4.0", "webpack-target-electron-renderer": "^0.4.0",

View file

@ -1,23 +1,23 @@
const path = require('path'); const path = require("path");
const webpack = require('webpack') const webpack = require("webpack")
const appPath = path.resolve(__dirname, 'js'); const appPath = path.resolve(__dirname, "js");
const PATHS = { const PATHS = {
app: path.join(__dirname, 'app'), app: path.join(__dirname, "app"),
dist: path.join(__dirname, 'dist') dist: path.join(__dirname, "dist")
}; };
module.exports = { module.exports = {
entry: ['babel-polyfill', './js/main.js'], entry: ["babel-polyfill", "./js/main.js"],
output: { output: {
path: path.join(PATHS.dist, 'js'), path: path.join(PATHS.dist, "js"),
publicPath: '/js/', publicPath: "/js/",
filename: "bundle.js" filename: "bundle.js"
}, },
devtool: 'source-map', devtool: "source-map",
resolve: { resolve: {
root: appPath, modules: [appPath, "node_modules"],
extensions: ['', '.js', '.jsx', '.css'], extensions: [".js", ".jsx", ".css"]
}, },
plugins: [ plugins: [
new webpack.DefinePlugin({ new webpack.DefinePlugin({
@ -25,29 +25,30 @@ module.exports = {
}), }),
], ],
module: { module: {
preLoaders: [ rules: [
{ {
test: /\.jsx?$/, test: /\.jsx?$/,
loaders: ['eslint'], enforce: "pre",
loaders: ["eslint"],
// define an include so we check just the files we need // define an include so we check just the files we need
include: PATHS.app include: PATHS.app
} },
], {
loaders: [ test: /\.css$/,
{ test: /\.css$/, loader: "style!css" }, use: ["style-loader", "css-loader"]
},
{ {
test: /\.jsx?$/, test: /\.jsx?$/,
loader: 'babel', exclude: /node_modules/,
query: { use: {
loader: "babel-loader",
options: {
cacheDirectory: true, cacheDirectory: true,
presets:[ 'es2015', 'react', 'stage-2' ] presets: [ "es2015", "react", "stage-2" ]
}
}
} }
},
{
test: /mime\.json$/,
loader: 'json',
},
] ]
}, },
target: 'electron-main', target: "electron-main",
}; };

View file

@ -1,59 +1,62 @@
const path = require('path'); const path = require("path");
const webpack = require('webpack') const webpack = require("webpack")
const WebpackNotifierPlugin = require('webpack-notifier') const WebpackNotifierPlugin = require("webpack-notifier")
const appPath = path.resolve(__dirname, 'js'); const appPath = path.resolve(__dirname, "js");
const PATHS = { const PATHS = {
app: path.join(__dirname, 'app'), app: path.join(__dirname, "app"),
dist: path.join(__dirname, '..', 'app', 'dist') dist: path.join(__dirname, "..", "app", "dist")
}; };
module.exports = { module.exports = {
entry: ['babel-polyfill', './js/main.js'], entry: ["babel-polyfill", "./js/main.js"],
output: { output: {
path: path.join(PATHS.dist, 'js'), path: path.join(PATHS.dist, "js"),
publicPath: '/js/', publicPath: "/js/",
filename: "bundle.js", filename: "bundle.js",
pathinfo: true pathinfo: true
}, },
debug: true,
cache: true, cache: true,
devtool: 'eval', devtool: "eval",
resolve: { resolve: {
root: appPath, modules: [appPath, "node_modules"],
extensions: ['', '.js', '.jsx', '.css'], extensions: [".js", ".jsx", ".css"]
}, },
plugins: [ plugins: [
new WebpackNotifierPlugin(), new WebpackNotifierPlugin(),
new webpack.DefinePlugin({ new webpack.DefinePlugin({
ENV: JSON.stringify("development"), ENV: JSON.stringify("development"),
}), }),
new webpack.LoaderOptionsPlugin({
debug: true
})
], ],
module: { module: {
preLoaders: [ rules: [
{ {
test: /\.jsx?$/, test: /\.jsx?$/,
loaders: ['eslint'], enforce: "pre",
loaders: ["eslint"],
// define an include so we check just the files we need // define an include so we check just the files we need
include: PATHS.app include: PATHS.app
} },
], {
loaders: [ test: /\.css$/,
{ test: /\.css$/, loader: "style!css" }, use: ["style-loader", "css-loader"]
},
{ {
test: /\.jsx?$/, test: /\.jsx?$/,
loader: 'babel', exclude: /node_modules/,
query: { use: {
loader: "babel-loader",
options: {
cacheDirectory: true, cacheDirectory: true,
presets:[ 'es2015', 'react', 'stage-2' ] presets: [ "es2015", "react", "stage-2" ]
}
}
} }
},
{
test: /mime\.json$/,
loader: 'json',
},
] ]
}, },
target: 'electron-main', target: "electron-main",
}; };