-
Notifications
You must be signed in to change notification settings - Fork 17
Open
Description
Great job, This plugin works great, and I really like it.
I'm stuck in making this plugin works with watch mode.
The use case is:
- we get programmatically source file content and build it to complex component (multiple replacements, imports and etc)
- we pass build string content to entry point via your plugin to webpack config
- webpack builds this file fine and package is working fine.
Now we want to run watcher when source file is changed:
this should trigger:
- build from source files to string
- update entry point
- webpack should rerun build chunk (not full build just this single changed entry point)
Any advice will be helpfull, the case is not so standard, we use multiple source files like templates then build it inside webpack file like:
import webpack from 'webpack'
import path from 'path'
import ExtractTextPlugin from 'extract-text-webpack-plugin'
import autoprefixer from 'autoprefixer'
import grab from 'ps-grab'
import VirtualModulePlugin from 'virtual-module-webpack-plugin'
import ElementCollector from './tools/webpack/elementsCollector'
import ElementsBuilder from './tools/webpack/elementsBuilder'
let config = {
// devtool: 'eval',
entry: {
vendor: [
'react',
'react-dom',
'classnames',
'lodash',
'./node_modules/babel-runtime/core-js.js',
'./node_modules/babel-runtime/helpers/createClass.js',
'./node_modules/babel-runtime/helpers/inherits.js',
'./node_modules/babel-runtime/helpers/typeof.js',
'./node_modules/babel-runtime/helpers/possibleConstructorReturn.js',
'./node_modules/babel-runtime/helpers/classCallCheck.js',
'./node_modules/babel-runtime/helpers/extends.js',
'./node_modules/babel-runtime/core-js/symbol.js',
'./node_modules/babel-runtime/core-js/symbol/iterator.js',
'./node_modules/babel-runtime/core-js/object/set-prototype-of.js',
'./node_modules/babel-runtime/core-js/object/get-prototype-of.js',
'./node_modules/babel-runtime/core-js/object/define-property.js',
'./node_modules/babel-runtime/core-js/object/create.js',
'./node_modules/babel-runtime/core-js/object/assign.js',
'./node_modules/babel-runtime/core-js/object/keys.js'
]
},
output: {
path: path.resolve(__dirname, './public/dist/'), // Assets dist path
publicPath: '.', // Used to generate URL's
filename: '[name].bundle.js', // Main bundle file
chunkFilename: '[id].js'
},
node: {
fs: 'empty'
},
module: {
....
},
plugins: [
new webpack.optimize.CommonsChunkPlugin({
name: 'vendor'
}),
new ExtractTextPlugin('[name].bundle.css'),
// new webpack.optimize.UglifyJsPlugin({
// output: {
// comments: false
// }
// })
// new webpack.HotModuleReplacementPlugin(),
new webpack.NamedModulesPlugin()
]
}
let argv = process.argv
if (argv.indexOf('--quick') === -1) {
// Get elements and push VirtualModulePlugin
const elements = ElementCollector.getElements()
let single = grab('--element')
elements.forEach((item) => {
let elementName = item.element
if (!single || single && single === elementName) {
let elementPath = item.path
let template = (ElementsBuilder.generateOutput(elementPath, {
'--uuid': elementName
}))
if (template) {
config.plugins.push(
new VirtualModulePlugin({
moduleName: `${elementName}.js`,
path: path.resolve(__dirname, `public/elements/${elementName}.js`),
contents: template
})
)
config.entry[ `element-${elementName}` ] = `./public/elements/${elementName}.js`
}
}
})
}
The problem is that public/elements/[some-element].js is not under webpack scope (no entry points)
tswaters, FrancescoCioria and ndelangen
Metadata
Metadata
Assignees
Labels
No labels