webpack upgrade

This commit is contained in:
daniel-j 2016-11-21 13:57:05 +01:00
parent b2717c6ee3
commit c2234018d7
4 changed files with 29 additions and 34 deletions

View file

@ -33,21 +33,20 @@ webpackConfig.forEach((c) => {
minimize: true, minimize: true,
debug: false debug: false
})) }))
c.plugins.push(new webpack.optimize.DedupePlugin()) /*
if (c.uglify) { c.plugins.push(new webpack.optimize.UglifyJsPlugin({
c.plugins.push(new webpack.optimize.UglifyJsPlugin({ compress: {
compress: { warnings: false,
warnings: false, screw_ie8: true
screw_ie8: true },
}, comments: false,
comments: false, mangle: {
mangle: { screw_ie8: true
screw_ie8: true },
}, screw_ie8: true,
screw_ie8: true, sourceMap: !!c.devtool
sourceMap: !!c.devtool }))
})) */
}
} }
c.plugins.push(new webpack.DefinePlugin({ c.plugins.push(new webpack.DefinePlugin({
FIMFIC2EPUB_VERSION: JSON.stringify(require('./package.json').version) FIMFIC2EPUB_VERSION: JSON.stringify(require('./package.json').version)

View file

@ -9,7 +9,7 @@ import isNode from 'detect-node'
let tidy let tidy
if (!isNode) { if (!isNode) {
tidy = require('exports?tidy_html5!tidy-html5') tidy = require('exports-loader?tidy_html5!tidy-html5')
} else { } else {
tidy = require('tidy-html5').tidy_html5 tidy = require('tidy-html5').tidy_html5
} }

View file

@ -1,5 +1,5 @@
export let NS = { export const NS = {
OPF: 'http://www.idpf.org/2007/opf', OPF: 'http://www.idpf.org/2007/opf',
OPS: 'http://www.idpf.org/2007/ops', OPS: 'http://www.idpf.org/2007/ops',
DC: 'http://purl.org/dc/elements/1.1/', DC: 'http://purl.org/dc/elements/1.1/',
@ -9,7 +9,7 @@ export let NS = {
XLINK: 'http://www.w3.org/1999/xlink' XLINK: 'http://www.w3.org/1999/xlink'
} }
export let tidyOptions = { export const tidyOptions = {
'indent': 'auto', 'indent': 'auto',
'numeric-entities': 'yes', 'numeric-entities': 'yes',
'output-xhtml': 'yes', 'output-xhtml': 'yes',
@ -22,11 +22,11 @@ export let tidyOptions = {
'show-body-only': 'auto' 'show-body-only': 'auto'
} }
export let containerXml = `<?xml version="1.0" encoding="UTF-8"?> export const containerXml = `<?xml version="1.0" encoding="UTF-8"?>
<container version="1.0" xmlns="urn:oasis:names:tc:opendocument:xmlns:container"> <container version="1.0" xmlns="urn:oasis:names:tc:opendocument:xmlns:container">
<rootfiles> <rootfiles>
<rootfile full-path="OEBPS/content.opf" media-type="application/oebps-package+xml"/> <rootfile full-path="OEBPS/content.opf" media-type="application/oebps-package+xml"/>
</rootfiles> </rootfiles>
</container> </container>
` `
export let youtubeKey = 'AIzaSyCF1taix0lTr7-e_XBZazIXfAr8IvxTJhA' export const youtubeKey = 'AIzaSyCF1taix0lTr7-e_XBZazIXfAr8IvxTJhA'

View file

@ -16,10 +16,10 @@ const bundleExtensionConfig = {
}, },
module: { module: {
loaders: [ rules: [
{ {
test: /\.js$/, test: /\.js$/,
loader: 'babel', use: 'babel-loader',
exclude: /node_modules/, exclude: /node_modules/,
query: { query: {
sourceMaps: true, sourceMaps: true,
@ -28,7 +28,7 @@ const bundleExtensionConfig = {
}, },
{ {
test: /\.styl$/, test: /\.styl$/,
loader: 'raw-loader!stylus-loader' use: ['raw-loader', 'stylus-loader']
} }
], ],
noParse: [ noParse: [
@ -37,7 +37,7 @@ const bundleExtensionConfig = {
}, },
resolve: { resolve: {
extensions: ['', '.js', '.json', '.styl'], extensions: ['.js', '.json', '.styl'],
modules: [ modules: [
path.resolve('./src'), path.resolve('./src'),
'node_modules' 'node_modules'
@ -50,9 +50,7 @@ const bundleExtensionConfig = {
externals: ['request', 'tidy-html5'], externals: ['request', 'tidy-html5'],
plugins: [], plugins: [],
devtool: 'source-map', devtool: 'source-map'
debug: true,
uglify: inProduction
} }
const bundleNpmModuleConfig = { const bundleNpmModuleConfig = {
@ -67,10 +65,10 @@ const bundleNpmModuleConfig = {
target: 'node', target: 'node',
module: { module: {
loaders: [ rules: [
{ {
test: /\.js$/, test: /\.js$/,
loader: 'babel', use: 'babel-loader',
exclude: /node_modules/, exclude: /node_modules/,
query: { query: {
sourceMaps: !inProduction, sourceMaps: !inProduction,
@ -79,7 +77,7 @@ const bundleNpmModuleConfig = {
}, },
{ {
test: /\.styl$/, test: /\.styl$/,
loader: 'raw-loader!stylus-loader' use: ['raw-loader', 'stylus-loader']
} }
], ],
noParse: [ noParse: [
@ -88,7 +86,7 @@ const bundleNpmModuleConfig = {
}, },
resolve: { resolve: {
extensions: ['', '.js', '.json', '.styl'], extensions: ['.js', '.json', '.styl'],
modules: [ modules: [
path.resolve('./src'), path.resolve('./src'),
'node_modules' 'node_modules'
@ -98,9 +96,7 @@ const bundleNpmModuleConfig = {
externals: [nodeExternals({whitelist: ['es6-event-emitter', /^babel-runtime/]}), 'exports?tidy_html5!tidy-html5'], externals: [nodeExternals({whitelist: ['es6-event-emitter', /^babel-runtime/]}), 'exports?tidy_html5!tidy-html5'],
plugins: [], plugins: [],
devtool: 'source-map', devtool: 'source-map'
debug: true,
uglify: inProduction
} }
export default [bundleExtensionConfig, bundleNpmModuleConfig] export default [bundleExtensionConfig, bundleNpmModuleConfig]